
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 09/19/2011 12:39:07
-- Generated from EDMX file: E:\PVT PROJECTS\Risk And Compliance\MVC RC\Host\Host\Models\Data.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [bluegrape.co.za];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK__aspnet_Me__Appli__68D28DBC]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[aspnet_Membership] DROP CONSTRAINT [FK__aspnet_Me__Appli__68D28DBC];
GO
IF OBJECT_ID(N'[dbo].[FK__aspnet_Me__UserI__69C6B1F5]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[aspnet_Membership] DROP CONSTRAINT [FK__aspnet_Me__UserI__69C6B1F5];
GO
IF OBJECT_ID(N'[dbo].[FK__aspnet_Pa__Appli__1A69E950]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[aspnet_Paths] DROP CONSTRAINT [FK__aspnet_Pa__Appli__1A69E950];
GO
IF OBJECT_ID(N'[dbo].[FK__aspnet_Pe__PathI__2022C2A6]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[aspnet_PersonalizationAllUsers] DROP CONSTRAINT [FK__aspnet_Pe__PathI__2022C2A6];
GO
IF OBJECT_ID(N'[dbo].[FK__aspnet_Pe__PathI__23F3538A]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[aspnet_PersonalizationPerUser] DROP CONSTRAINT [FK__aspnet_Pe__PathI__23F3538A];
GO
IF OBJECT_ID(N'[dbo].[FK__aspnet_Pe__UserI__24E777C3]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[aspnet_PersonalizationPerUser] DROP CONSTRAINT [FK__aspnet_Pe__UserI__24E777C3];
GO
IF OBJECT_ID(N'[dbo].[FK__aspnet_Pr__UserI__7DCDAAA2]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[aspnet_Profile] DROP CONSTRAINT [FK__aspnet_Pr__UserI__7DCDAAA2];
GO
IF OBJECT_ID(N'[dbo].[FK__aspnet_Ro__Appli__075714DC]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[aspnet_Roles] DROP CONSTRAINT [FK__aspnet_Ro__Appli__075714DC];
GO
IF OBJECT_ID(N'[dbo].[FK__aspnet_Us__Appli__589C25F3]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[aspnet_Users] DROP CONSTRAINT [FK__aspnet_Us__Appli__589C25F3];
GO
IF OBJECT_ID(N'[dbo].[FK__aspnet_Us__RoleI__0C1BC9F9]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[aspnet_UsersInRoles] DROP CONSTRAINT [FK__aspnet_Us__RoleI__0C1BC9F9];
GO
IF OBJECT_ID(N'[dbo].[FK__aspnet_Us__UserI__0B27A5C0]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[aspnet_UsersInRoles] DROP CONSTRAINT [FK__aspnet_Us__UserI__0B27A5C0];
GO
IF OBJECT_ID(N'[dbo].[FK_AnswerOption_Question]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[AnswerOption] DROP CONSTRAINT [FK_AnswerOption_Question];
GO
IF OBJECT_ID(N'[dbo].[FK_AuditComm_QuestionGroup]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Question] DROP CONSTRAINT [FK_AuditComm_QuestionGroup];
GO
IF OBJECT_ID(N'[dbo].[FK_Employer_EmployerStatus]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Employer] DROP CONSTRAINT [FK_Employer_EmployerStatus];
GO
IF OBJECT_ID(N'[dbo].[FK_Employer_Fund]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Employer] DROP CONSTRAINT [FK_Employer_Fund];
GO
IF OBJECT_ID(N'[dbo].[FK_FundAnswerSheet_Fund]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FundAnswerSheet] DROP CONSTRAINT [FK_FundAnswerSheet_Fund];
GO
IF OBJECT_ID(N'[dbo].[FK_FundAnswerSheet_Question]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FundAnswerSheet] DROP CONSTRAINT [FK_FundAnswerSheet_Question];
GO
IF OBJECT_ID(N'[dbo].[FK_FundElectedPeriod_Fund]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FundElectedPeriod] DROP CONSTRAINT [FK_FundElectedPeriod_Fund];
GO
IF OBJECT_ID(N'[dbo].[FK_FundElectedPeriodTrustee_FundElectedPeriod]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FundElectedPeriodTrustee] DROP CONSTRAINT [FK_FundElectedPeriodTrustee_FundElectedPeriod];
GO
IF OBJECT_ID(N'[dbo].[FK_FundSLA_Fund]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FundSLA] DROP CONSTRAINT [FK_FundSLA_Fund];
GO
IF OBJECT_ID(N'[dbo].[FK_Member_Employer]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Member] DROP CONSTRAINT [FK_Member_Employer];
GO
IF OBJECT_ID(N'[dbo].[FK_Member_Language]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Member] DROP CONSTRAINT [FK_Member_Language];
GO
IF OBJECT_ID(N'[dbo].[FK_Member_MemberStatus]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Member] DROP CONSTRAINT [FK_Member_MemberStatus];
GO
IF OBJECT_ID(N'[dbo].[FK_Member_RemunerationType]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Member] DROP CONSTRAINT [FK_Member_RemunerationType];
GO
IF OBJECT_ID(N'[dbo].[FK_MemberClaim_ClaimPaymentStatus]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[MemberClaim] DROP CONSTRAINT [FK_MemberClaim_ClaimPaymentStatus];
GO
IF OBJECT_ID(N'[dbo].[FK_MemberClaim_ClaimType]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[MemberClaim] DROP CONSTRAINT [FK_MemberClaim_ClaimType];
GO
IF OBJECT_ID(N'[dbo].[FK_MemberClaim_Member]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[MemberClaim] DROP CONSTRAINT [FK_MemberClaim_Member];
GO
IF OBJECT_ID(N'[dbo].[FK_MemberPayment_MemberClaim]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[MemberPayment] DROP CONSTRAINT [FK_MemberPayment_MemberClaim];
GO
IF OBJECT_ID(N'[dbo].[FK_MemberPayment_PaymentMethod]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[MemberPayment] DROP CONSTRAINT [FK_MemberPayment_PaymentMethod];
GO
IF OBJECT_ID(N'[dbo].[FK_MemberPayment_PaymentStatus]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[MemberPayment] DROP CONSTRAINT [FK_MemberPayment_PaymentStatus];
GO
IF OBJECT_ID(N'[dbo].[FK_MemberPayment_PaymentType]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[MemberPayment] DROP CONSTRAINT [FK_MemberPayment_PaymentType];
GO
IF OBJECT_ID(N'[dbo].[FK_MemberTransaction_ContributionType]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[MemberTransaction] DROP CONSTRAINT [FK_MemberTransaction_ContributionType];
GO
IF OBJECT_ID(N'[dbo].[FK_MemberTransaction_ContributionType1]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[MemberTransaction] DROP CONSTRAINT [FK_MemberTransaction_ContributionType1];
GO
IF OBJECT_ID(N'[dbo].[FK_MemberTransaction_ContributionType2]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[MemberTransaction] DROP CONSTRAINT [FK_MemberTransaction_ContributionType2];
GO
IF OBJECT_ID(N'[dbo].[FK_MemberTransaction_Member]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[MemberTransaction] DROP CONSTRAINT [FK_MemberTransaction_Member];
GO
IF OBJECT_ID(N'[dbo].[FK_People_Position]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Person] DROP CONSTRAINT [FK_People_Position];
GO
IF OBJECT_ID(N'[dbo].[FK_People_Title]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Person] DROP CONSTRAINT [FK_People_Title];
GO
IF OBJECT_ID(N'[dbo].[FK_Person_Client]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Person] DROP CONSTRAINT [FK_Person_Client];
GO
IF OBJECT_ID(N'[dbo].[FK_Person_Employer]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Person] DROP CONSTRAINT [FK_Person_Employer];
GO
IF OBJECT_ID(N'[dbo].[FK_Person_PersonType]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Person] DROP CONSTRAINT [FK_Person_PersonType];
GO
IF OBJECT_ID(N'[dbo].[FK_Question_AnswerDataType]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Question] DROP CONSTRAINT [FK_Question_AnswerDataType];
GO
IF OBJECT_ID(N'[dbo].[FK_QuestionGroup_Category]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[QuestionGroup] DROP CONSTRAINT [FK_QuestionGroup_Category];
GO
IF OBJECT_ID(N'[dbo].[FK_uaGroupRole_uaGroup]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[uaGroupRole] DROP CONSTRAINT [FK_uaGroupRole_uaGroup];
GO
IF OBJECT_ID(N'[dbo].[FK_uaGroupRole_uaRole]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[uaGroupRole] DROP CONSTRAINT [FK_uaGroupRole_uaRole];
GO
IF OBJECT_ID(N'[dbo].[FK_uaUserFund_Fund]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[uaUserFund] DROP CONSTRAINT [FK_uaUserFund_Fund];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[audit].[AuditFundAnswerSheet]', 'U') IS NOT NULL
    DROP TABLE [audit].[AuditFundAnswerSheet];
GO
IF OBJECT_ID(N'[audit].[AuditPerson]', 'U') IS NOT NULL
    DROP TABLE [audit].[AuditPerson];
GO
IF OBJECT_ID(N'[dbo].[AnswerDataType]', 'U') IS NOT NULL
    DROP TABLE [dbo].[AnswerDataType];
GO
IF OBJECT_ID(N'[dbo].[AnswerOption]', 'U') IS NOT NULL
    DROP TABLE [dbo].[AnswerOption];
GO
IF OBJECT_ID(N'[dbo].[aspnet_Applications]', 'U') IS NOT NULL
    DROP TABLE [dbo].[aspnet_Applications];
GO
IF OBJECT_ID(N'[dbo].[aspnet_Membership]', 'U') IS NOT NULL
    DROP TABLE [dbo].[aspnet_Membership];
GO
IF OBJECT_ID(N'[dbo].[aspnet_Paths]', 'U') IS NOT NULL
    DROP TABLE [dbo].[aspnet_Paths];
GO
IF OBJECT_ID(N'[dbo].[aspnet_PersonalizationAllUsers]', 'U') IS NOT NULL
    DROP TABLE [dbo].[aspnet_PersonalizationAllUsers];
GO
IF OBJECT_ID(N'[dbo].[aspnet_PersonalizationPerUser]', 'U') IS NOT NULL
    DROP TABLE [dbo].[aspnet_PersonalizationPerUser];
GO
IF OBJECT_ID(N'[dbo].[aspnet_Profile]', 'U') IS NOT NULL
    DROP TABLE [dbo].[aspnet_Profile];
GO
IF OBJECT_ID(N'[dbo].[aspnet_Roles]', 'U') IS NOT NULL
    DROP TABLE [dbo].[aspnet_Roles];
GO
IF OBJECT_ID(N'[dbo].[aspnet_SchemaVersions]', 'U') IS NOT NULL
    DROP TABLE [dbo].[aspnet_SchemaVersions];
GO
IF OBJECT_ID(N'[dbo].[aspnet_Users]', 'U') IS NOT NULL
    DROP TABLE [dbo].[aspnet_Users];
GO
IF OBJECT_ID(N'[dbo].[aspnet_UsersInRoles]', 'U') IS NOT NULL
    DROP TABLE [dbo].[aspnet_UsersInRoles];
GO
IF OBJECT_ID(N'[dbo].[aspnet_WebEvent_Events]', 'U') IS NOT NULL
    DROP TABLE [dbo].[aspnet_WebEvent_Events];
GO
IF OBJECT_ID(N'[dbo].[ClaimPaymentStatus]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ClaimPaymentStatus];
GO
IF OBJECT_ID(N'[dbo].[ClaimType]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ClaimType];
GO
IF OBJECT_ID(N'[dbo].[Client]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Client];
GO
IF OBJECT_ID(N'[dbo].[ContributionType]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ContributionType];
GO
IF OBJECT_ID(N'[dbo].[Employer]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Employer];
GO
IF OBJECT_ID(N'[dbo].[EmployerFileData]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EmployerFileData];
GO
IF OBJECT_ID(N'[dbo].[EmployerFileFooter]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EmployerFileFooter];
GO
IF OBJECT_ID(N'[dbo].[EmployerFileHeader]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EmployerFileHeader];
GO
IF OBJECT_ID(N'[dbo].[EmployerStatus]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EmployerStatus];
GO
IF OBJECT_ID(N'[dbo].[Exception]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Exception];
GO
IF OBJECT_ID(N'[dbo].[FileExceptionLog]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FileExceptionLog];
GO
IF OBJECT_ID(N'[dbo].[FileImportType]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FileImportType];
GO
IF OBJECT_ID(N'[dbo].[FileLog]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FileLog];
GO
IF OBJECT_ID(N'[dbo].[FileProcessStatus]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FileProcessStatus];
GO
IF OBJECT_ID(N'[dbo].[Fund]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Fund];
GO
IF OBJECT_ID(N'[dbo].[FundAnswerSheet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FundAnswerSheet];
GO
IF OBJECT_ID(N'[dbo].[FundElectedPeriod]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FundElectedPeriod];
GO
IF OBJECT_ID(N'[dbo].[FundElectedPeriodTrustee]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FundElectedPeriodTrustee];
GO
IF OBJECT_ID(N'[dbo].[FundSLA]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FundSLA];
GO
IF OBJECT_ID(N'[dbo].[Language]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Language];
GO
IF OBJECT_ID(N'[dbo].[Map]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Map];
GO
IF OBJECT_ID(N'[dbo].[Member]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Member];
GO
IF OBJECT_ID(N'[dbo].[MemberClaim]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberClaim];
GO
IF OBJECT_ID(N'[dbo].[MemberClaimExceptionLog]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberClaimExceptionLog];
GO
IF OBJECT_ID(N'[dbo].[MemberClaimFileData]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberClaimFileData];
GO
IF OBJECT_ID(N'[dbo].[MemberClaimFileFooter]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberClaimFileFooter];
GO
IF OBJECT_ID(N'[dbo].[MemberClaimFileHeader]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberClaimFileHeader];
GO
IF OBJECT_ID(N'[dbo].[MemberExceptionLog]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberExceptionLog];
GO
IF OBJECT_ID(N'[dbo].[MemberFileData]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberFileData];
GO
IF OBJECT_ID(N'[dbo].[MemberFileFooter]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberFileFooter];
GO
IF OBJECT_ID(N'[dbo].[MemberFileHeader]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberFileHeader];
GO
IF OBJECT_ID(N'[dbo].[MemberPayment]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberPayment];
GO
IF OBJECT_ID(N'[dbo].[MemberPaymentFileData]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberPaymentFileData];
GO
IF OBJECT_ID(N'[dbo].[MemberPaymentFileFooter]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberPaymentFileFooter];
GO
IF OBJECT_ID(N'[dbo].[MemberPaymentFileHeader]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberPaymentFileHeader];
GO
IF OBJECT_ID(N'[dbo].[MemberStatus]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberStatus];
GO
IF OBJECT_ID(N'[dbo].[MemberTransaction]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberTransaction];
GO
IF OBJECT_ID(N'[dbo].[MemberTransactionFileData]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberTransactionFileData];
GO
IF OBJECT_ID(N'[dbo].[MemberTransactionFileFooter]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberTransactionFileFooter];
GO
IF OBJECT_ID(N'[dbo].[MemberTransactionFileHeader]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberTransactionFileHeader];
GO
IF OBJECT_ID(N'[dbo].[NotificationLog]', 'U') IS NOT NULL
    DROP TABLE [dbo].[NotificationLog];
GO
IF OBJECT_ID(N'[dbo].[PaymentMethod]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PaymentMethod];
GO
IF OBJECT_ID(N'[dbo].[PaymentStatus]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PaymentStatus];
GO
IF OBJECT_ID(N'[dbo].[PaymentType]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PaymentType];
GO
IF OBJECT_ID(N'[dbo].[Person]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Person];
GO
IF OBJECT_ID(N'[dbo].[PersonType]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PersonType];
GO
IF OBJECT_ID(N'[dbo].[Position]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Position];
GO
IF OBJECT_ID(N'[dbo].[Question]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Question];
GO
IF OBJECT_ID(N'[dbo].[QuestionCategory]', 'U') IS NOT NULL
    DROP TABLE [dbo].[QuestionCategory];
GO
IF OBJECT_ID(N'[dbo].[QuestionGroup]', 'U') IS NOT NULL
    DROP TABLE [dbo].[QuestionGroup];
GO
IF OBJECT_ID(N'[dbo].[Reg]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Reg];
GO
IF OBJECT_ID(N'[dbo].[RegGroup]', 'U') IS NOT NULL
    DROP TABLE [dbo].[RegGroup];
GO
IF OBJECT_ID(N'[dbo].[RemunerationType]', 'U') IS NOT NULL
    DROP TABLE [dbo].[RemunerationType];
GO
IF OBJECT_ID(N'[dbo].[Title]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Title];
GO
IF OBJECT_ID(N'[dbo].[uaGroup]', 'U') IS NOT NULL
    DROP TABLE [dbo].[uaGroup];
GO
IF OBJECT_ID(N'[dbo].[uaGroupRole]', 'U') IS NOT NULL
    DROP TABLE [dbo].[uaGroupRole];
GO
IF OBJECT_ID(N'[dbo].[uaRole]', 'U') IS NOT NULL
    DROP TABLE [dbo].[uaRole];
GO
IF OBJECT_ID(N'[dbo].[uaUserFund]', 'U') IS NOT NULL
    DROP TABLE [dbo].[uaUserFund];
GO
IF OBJECT_ID(N'[dbo].[uaUserGroup]', 'U') IS NOT NULL
    DROP TABLE [dbo].[uaUserGroup];
GO
IF OBJECT_ID(N'[bluegrapecozaModelStoreContainer].[vw_ActiveQuestionGroup]', 'U') IS NOT NULL
    DROP TABLE [bluegrapecozaModelStoreContainer].[vw_ActiveQuestionGroup];
GO
IF OBJECT_ID(N'[bluegrapecozaModelStoreContainer].[vw_aspnet_Applications]', 'U') IS NOT NULL
    DROP TABLE [bluegrapecozaModelStoreContainer].[vw_aspnet_Applications];
GO
IF OBJECT_ID(N'[bluegrapecozaModelStoreContainer].[vw_aspnet_MembershipUsers]', 'U') IS NOT NULL
    DROP TABLE [bluegrapecozaModelStoreContainer].[vw_aspnet_MembershipUsers];
GO
IF OBJECT_ID(N'[bluegrapecozaModelStoreContainer].[vw_aspnet_Profiles]', 'U') IS NOT NULL
    DROP TABLE [bluegrapecozaModelStoreContainer].[vw_aspnet_Profiles];
GO
IF OBJECT_ID(N'[bluegrapecozaModelStoreContainer].[vw_aspnet_Roles]', 'U') IS NOT NULL
    DROP TABLE [bluegrapecozaModelStoreContainer].[vw_aspnet_Roles];
GO
IF OBJECT_ID(N'[bluegrapecozaModelStoreContainer].[vw_aspnet_Users]', 'U') IS NOT NULL
    DROP TABLE [bluegrapecozaModelStoreContainer].[vw_aspnet_Users];
GO
IF OBJECT_ID(N'[bluegrapecozaModelStoreContainer].[vw_aspnet_UsersInRoles]', 'U') IS NOT NULL
    DROP TABLE [bluegrapecozaModelStoreContainer].[vw_aspnet_UsersInRoles];
GO
IF OBJECT_ID(N'[bluegrapecozaModelStoreContainer].[vw_aspnet_WebPartState_Paths]', 'U') IS NOT NULL
    DROP TABLE [bluegrapecozaModelStoreContainer].[vw_aspnet_WebPartState_Paths];
GO
IF OBJECT_ID(N'[bluegrapecozaModelStoreContainer].[vw_aspnet_WebPartState_Shared]', 'U') IS NOT NULL
    DROP TABLE [bluegrapecozaModelStoreContainer].[vw_aspnet_WebPartState_Shared];
GO
IF OBJECT_ID(N'[bluegrapecozaModelStoreContainer].[vw_aspnet_WebPartState_User]', 'U') IS NOT NULL
    DROP TABLE [bluegrapecozaModelStoreContainer].[vw_aspnet_WebPartState_User];
GO
IF OBJECT_ID(N'[bluegrapecozaModelStoreContainer].[vw_ElectionPeriods]', 'U') IS NOT NULL
    DROP TABLE [bluegrapecozaModelStoreContainer].[vw_ElectionPeriods];
GO
IF OBJECT_ID(N'[bluegrapecozaModelStoreContainer].[vw_FundAdministratorFund]', 'U') IS NOT NULL
    DROP TABLE [bluegrapecozaModelStoreContainer].[vw_FundAdministratorFund];
GO
IF OBJECT_ID(N'[bluegrapecozaModelStoreContainer].[vw_FundAdministratorUsers]', 'U') IS NOT NULL
    DROP TABLE [bluegrapecozaModelStoreContainer].[vw_FundAdministratorUsers];
GO
IF OBJECT_ID(N'[bluegrapecozaModelStoreContainer].[vw_SystemUsers]', 'U') IS NOT NULL
    DROP TABLE [bluegrapecozaModelStoreContainer].[vw_SystemUsers];
GO
IF OBJECT_ID(N'[bluegrapecozaModelStoreContainer].[vw_TrusteeFund]', 'U') IS NOT NULL
    DROP TABLE [bluegrapecozaModelStoreContainer].[vw_TrusteeFund];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'AuditFundAnswerSheet'
CREATE TABLE [dbo].[AuditFundAnswerSheet] (
    [AuditFundAnswerSheetId] bigint IDENTITY(1,1) NOT NULL,
    [FundAnswerSheetId] int  NOT NULL,
    [QuestionId] int  NOT NULL,
    [FundId] int  NOT NULL,
    [AnswerValue] varchar(255)  NULL,
    [AnswerOptionId] int  NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] nvarchar(255)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] nvarchar(255)  NULL,
    [AuditChangeType] char(1)  NOT NULL,
    [AuditChangeSQLUser] varchar(255)  NOT NULL,
    [AuditChangeDateTime] datetime  NOT NULL
);
GO

-- Creating table 'AuditPerson'
CREATE TABLE [dbo].[AuditPerson] (
    [AuditPersonId] bigint IDENTITY(1,1) NOT NULL,
    [PersonId] int  NOT NULL,
    [PersonTypeId] int  NOT NULL,
    [TitleId] int  NULL,
    [PositionId] int  NULL,
    [ClientId] int  NULL,
    [EmployerId] int  NULL,
    [Password] nvarchar(50)  NULL,
    [PasswordChangedDate] datetime  NULL,
    [FullName] nvarchar(100)  NOT NULL,
    [Email] nvarchar(255)  NOT NULL,
    [Cellphone] varchar(10)  NULL,
    [WorkNo] varchar(10)  NULL,
    [PhysicalAddress] varchar(255)  NULL,
    [PostalAddress] varchar(255)  NULL,
    [Active] bit  NULL,
    [Notify] bit  NULL,
    [IsUser] bit  NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] nvarchar(255)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] nvarchar(255)  NULL,
    [AuditChangeType] char(1)  NOT NULL,
    [AuditChangeSQLUser] varchar(255)  NOT NULL,
    [AuditChangeDateTime] datetime  NOT NULL
);
GO

-- Creating table 'AnswerDataType'
CREATE TABLE [dbo].[AnswerDataType] (
    [AnswerDataTypeId] int  NOT NULL,
    [AnswerDataTypeDescription] varchar(255)  NULL
);
GO

-- Creating table 'AnswerOption'
CREATE TABLE [dbo].[AnswerOption] (
    [AnswerOptionId] int  NOT NULL,
    [AnswerDisplay] varchar(50)  NOT NULL,
    [AnswerValue] varchar(255)  NULL,
    [QuestionId] int  NULL
);
GO

-- Creating table 'aspnet_Applications'
CREATE TABLE [dbo].[aspnet_Applications] (
    [ApplicationName] nvarchar(256)  NOT NULL,
    [LoweredApplicationName] nvarchar(256)  NOT NULL,
    [ApplicationId] uniqueidentifier  NOT NULL,
    [Description] nvarchar(256)  NULL
);
GO

-- Creating table 'aspnet_Membership'
CREATE TABLE [dbo].[aspnet_Membership] (
    [ApplicationId] uniqueidentifier  NOT NULL,
    [UserId] uniqueidentifier  NOT NULL,
    [Password] nvarchar(128)  NOT NULL,
    [PasswordFormat] int  NOT NULL,
    [PasswordSalt] nvarchar(128)  NOT NULL,
    [MobilePIN] nvarchar(16)  NULL,
    [Email] nvarchar(256)  NULL,
    [LoweredEmail] nvarchar(256)  NULL,
    [PasswordQuestion] nvarchar(256)  NULL,
    [PasswordAnswer] nvarchar(128)  NULL,
    [IsApproved] bit  NOT NULL,
    [IsLockedOut] bit  NOT NULL,
    [CreateDate] datetime  NOT NULL,
    [LastLoginDate] datetime  NOT NULL,
    [LastPasswordChangedDate] datetime  NOT NULL,
    [LastLockoutDate] datetime  NOT NULL,
    [FailedPasswordAttemptCount] int  NOT NULL,
    [FailedPasswordAttemptWindowStart] datetime  NOT NULL,
    [FailedPasswordAnswerAttemptCount] int  NOT NULL,
    [FailedPasswordAnswerAttemptWindowStart] datetime  NOT NULL,
    [Comment] nvarchar(max)  NULL
);
GO

-- Creating table 'aspnet_Paths'
CREATE TABLE [dbo].[aspnet_Paths] (
    [ApplicationId] uniqueidentifier  NOT NULL,
    [PathId] uniqueidentifier  NOT NULL,
    [Path] nvarchar(256)  NOT NULL,
    [LoweredPath] nvarchar(256)  NOT NULL
);
GO

-- Creating table 'aspnet_PersonalizationAllUsers'
CREATE TABLE [dbo].[aspnet_PersonalizationAllUsers] (
    [PathId] uniqueidentifier  NOT NULL,
    [PageSettings] varbinary(max)  NOT NULL,
    [LastUpdatedDate] datetime  NOT NULL
);
GO

-- Creating table 'aspnet_PersonalizationPerUser'
CREATE TABLE [dbo].[aspnet_PersonalizationPerUser] (
    [Id] uniqueidentifier  NOT NULL,
    [PathId] uniqueidentifier  NULL,
    [UserId] uniqueidentifier  NULL,
    [PageSettings] varbinary(max)  NOT NULL,
    [LastUpdatedDate] datetime  NOT NULL
);
GO

-- Creating table 'aspnet_Profile'
CREATE TABLE [dbo].[aspnet_Profile] (
    [UserId] uniqueidentifier  NOT NULL,
    [PropertyNames] nvarchar(max)  NOT NULL,
    [PropertyValuesString] nvarchar(max)  NOT NULL,
    [PropertyValuesBinary] varbinary(max)  NOT NULL,
    [LastUpdatedDate] datetime  NOT NULL
);
GO

-- Creating table 'aspnet_Roles'
CREATE TABLE [dbo].[aspnet_Roles] (
    [ApplicationId] uniqueidentifier  NOT NULL,
    [RoleId] uniqueidentifier  NOT NULL,
    [RoleName] nvarchar(256)  NOT NULL,
    [LoweredRoleName] nvarchar(256)  NOT NULL,
    [Description] nvarchar(256)  NULL
);
GO

-- Creating table 'aspnet_SchemaVersions'
CREATE TABLE [dbo].[aspnet_SchemaVersions] (
    [Feature] nvarchar(128)  NOT NULL,
    [CompatibleSchemaVersion] nvarchar(128)  NOT NULL,
    [IsCurrentVersion] bit  NOT NULL
);
GO

-- Creating table 'aspnet_Users'
CREATE TABLE [dbo].[aspnet_Users] (
    [ApplicationId] uniqueidentifier  NOT NULL,
    [UserId] uniqueidentifier  NOT NULL,
    [UserName] nvarchar(256)  NOT NULL,
    [LoweredUserName] nvarchar(256)  NOT NULL,
    [MobileAlias] nvarchar(16)  NULL,
    [IsAnonymous] bit  NOT NULL,
    [LastActivityDate] datetime  NOT NULL
);
GO

-- Creating table 'aspnet_WebEvent_Events'
CREATE TABLE [dbo].[aspnet_WebEvent_Events] (
    [EventId] char(32)  NOT NULL,
    [EventTimeUtc] datetime  NOT NULL,
    [EventTime] datetime  NOT NULL,
    [EventType] nvarchar(256)  NOT NULL,
    [EventSequence] decimal(19,0)  NOT NULL,
    [EventOccurrence] decimal(19,0)  NOT NULL,
    [EventCode] int  NOT NULL,
    [EventDetailCode] int  NOT NULL,
    [Message] nvarchar(1024)  NULL,
    [ApplicationPath] nvarchar(256)  NULL,
    [ApplicationVirtualPath] nvarchar(256)  NULL,
    [MachineName] nvarchar(256)  NOT NULL,
    [RequestUrl] nvarchar(1024)  NULL,
    [ExceptionType] nvarchar(256)  NULL,
    [Details] nvarchar(max)  NULL
);
GO

-- Creating table 'ClaimPaymentStatus'
CREATE TABLE [dbo].[ClaimPaymentStatus] (
    [ClaimPaymentStatusId] char(1)  NOT NULL,
    [ClaimPaymentStatusDescription] varchar(100)  NOT NULL
);
GO

-- Creating table 'ClaimType'
CREATE TABLE [dbo].[ClaimType] (
    [ClaimTypeId] char(1)  NOT NULL,
    [ClaimTypeDescription] varchar(100)  NOT NULL
);
GO

-- Creating table 'Client'
CREATE TABLE [dbo].[Client] (
    [ClientId] int IDENTITY(1,1) NOT NULL,
    [ClientName] varchar(50)  NOT NULL,
    [PhysicalAddress] varchar(255)  NULL,
    [PostalAddress] varchar(255)  NULL,
    [Active] bit  NOT NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] nvarchar(255)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] nvarchar(255)  NULL
);
GO

-- Creating table 'ContributionType'
CREATE TABLE [dbo].[ContributionType] (
    [ContributionTypeId] char(1)  NOT NULL,
    [ContributionTypeDescription] varchar(100)  NOT NULL
);
GO

-- Creating table 'Employer'
CREATE TABLE [dbo].[Employer] (
    [EmployerId] int IDENTITY(1,1) NOT NULL,
    [FundId] int  NOT NULL,
    [EmployerNo] nvarchar(20)  NOT NULL,
    [EmployerName] varchar(50)  NOT NULL,
    [DateFundJoined] datetime  NULL,
    [EmployerStatusId] char(1)  NOT NULL,
    [NotificationDate] datetime  NULL,
    [ExitDate] datetime  NULL,
    [MemberCount] int  NOT NULL,
    [PhysicalAddress] varchar(255)  NULL,
    [PostalAddress] varchar(255)  NULL,
    [Active] bit  NULL,
    [EffectivePeriod] varchar(6)  NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] nvarchar(255)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] nvarchar(255)  NULL
);
GO

-- Creating table 'EmployerFileData'
CREATE TABLE [dbo].[EmployerFileData] (
    [EmployerFileDataId] bigint IDENTITY(1,1) NOT NULL,
    [FileLogId] int  NOT NULL,
    [EmployerNo] varchar(10)  NULL,
    [EmployerName] varchar(50)  NULL,
    [DateFundJoined] varchar(8)  NULL,
    [EmployerStatus] varchar(1)  NULL,
    [NotificationDate] varchar(8)  NULL,
    [ExitDate] varchar(8)  NULL,
    [MemberCount] varchar(15)  NULL,
    [ContactPersonName] varchar(100)  NULL,
    [ContactPersonEmail] varchar(250)  NULL,
    [ContactPersonCellNo] varchar(10)  NULL,
    [ContactPersonWorkNo] varchar(10)  NULL,
    [ImportDateTime] datetime  NOT NULL,
    [Notify] varchar(1)  NULL,
    [HasIssue] bit  NOT NULL
);
GO

-- Creating table 'EmployerFileFooter'
CREATE TABLE [dbo].[EmployerFileFooter] (
    [EmployerFileFooterId] bigint IDENTITY(1,1) NOT NULL,
    [FileLogId] int  NOT NULL,
    [TotalDataRecords] varchar(10)  NULL,
    [MemberCount] varchar(100)  NULL,
    [ImportDateTime] datetime  NULL,
    [HasIssue] bit  NOT NULL
);
GO

-- Creating table 'EmployerFileHeader'
CREATE TABLE [dbo].[EmployerFileHeader] (
    [EmployerFileHeaderId] bigint IDENTITY(1,1) NOT NULL,
    [FilelogId] int  NOT NULL,
    [FundNo] varchar(8)  NOT NULL,
    [DateFormat] varchar(8)  NOT NULL,
    [FileCreationDate] varchar(8)  NOT NULL,
    [EffectivePeriod] varchar(6)  NOT NULL,
    [ImportDateTime] datetime  NULL,
    [HasIssue] bit  NOT NULL
);
GO

-- Creating table 'EmployerStatus'
CREATE TABLE [dbo].[EmployerStatus] (
    [EmployerStatusId] char(1)  NOT NULL,
    [StatusDescription] varchar(100)  NOT NULL
);
GO

-- Creating table 'Exception'
CREATE TABLE [dbo].[Exception] (
    [ExceptionId] int  NOT NULL,
    [ImportArea] char(1)  NOT NULL,
    [ExceptionDescription] varchar(255)  NOT NULL,
    [QuestionId] int  NULL,
    [SheetId] int  NULL
);
GO

-- Creating table 'FileExceptionLog'
CREATE TABLE [dbo].[FileExceptionLog] (
    [FileExceptionlogId] bigint IDENTITY(1,1) NOT NULL,
    [FileLogId] int  NULL,
    [FileDetailId] int  NULL,
    [FileImportTypeId] char(1)  NULL,
    [ExceptionDescription] nvarchar(255)  NOT NULL,
    [RaisedDateTime] datetime  NOT NULL,
    [SourceId] int  NULL,
    [FundId] int  NULL,
    [LogUser] nvarchar(50)  NULL
);
GO

-- Creating table 'FileImportType'
CREATE TABLE [dbo].[FileImportType] (
    [FileImportTypeId] char(1)  NOT NULL,
    [FileImportTypeDescription] varchar(100)  NOT NULL
);
GO

-- Creating table 'FileLog'
CREATE TABLE [dbo].[FileLog] (
    [FileLogId] int IDENTITY(1,1) NOT NULL,
    [FundId] int  NOT NULL,
    [FileName] nvarchar(255)  NOT NULL,
    [FileImportTypeId] char(1)  NULL,
    [FileCreationDate] datetime  NULL,
    [EffectivePeriod] varchar(6)  NULL,
    [UploadPersonId] int  NOT NULL,
    [FileProcessStatusId] char(1)  NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] nvarchar(255)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] nvarchar(255)  NULL,
    [FileData] varbinary(max)  NULL,
    [UploadUser] uniqueidentifier  NULL
);
GO

-- Creating table 'FileProcessStatus'
CREATE TABLE [dbo].[FileProcessStatus] (
    [FileProcessStatusId] char(1)  NOT NULL,
    [FileProcessStatusDescription] varchar(100)  NOT NULL
);
GO

-- Creating table 'Fund'
CREATE TABLE [dbo].[Fund] (
    [FundId] int IDENTITY(1,1) NOT NULL,
    [FundNo] nvarchar(20)  NOT NULL,
    [ClientId] int  NOT NULL,
    [FundName] varchar(50)  NOT NULL,
    [EffectiveDate] datetime  NOT NULL,
    [ValidMonths] int  NOT NULL,
    [EndDate] datetime  NOT NULL,
    [PhysicalAddress] varchar(255)  NULL,
    [PostalAddress] varchar(255)  NULL,
    [Active] bit  NULL,
    [Logo] varbinary(max)  NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] varchar(100)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] varchar(100)  NULL
);
GO

-- Creating table 'FundAnswerSheet'
CREATE TABLE [dbo].[FundAnswerSheet] (
    [FundAnswerSheetId] int IDENTITY(1,1) NOT NULL,
    [QuestionId] int  NOT NULL,
    [FundId] int  NOT NULL,
    [AnswerValue] varchar(255)  NULL,
    [AnswerOptionId] int  NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] nvarchar(255)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] nvarchar(255)  NULL
);
GO

-- Creating table 'FundElectedPeriod'
CREATE TABLE [dbo].[FundElectedPeriod] (
    [FundElectedPeriodId] int IDENTITY(1,1) NOT NULL,
    [FundId] int  NOT NULL,
    [StartDate] datetime  NOT NULL,
    [EndDate] datetime  NOT NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] nvarchar(255)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] nvarchar(255)  NULL
);
GO

-- Creating table 'FundElectedPeriodTrustee'
CREATE TABLE [dbo].[FundElectedPeriodTrustee] (
    [FundElectedPeriodId] int  NOT NULL,
    [TrusteeId] int  NOT NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] nvarchar(255)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] nvarchar(255)  NULL
);
GO

-- Creating table 'FundSLA'
CREATE TABLE [dbo].[FundSLA] (
    [FundSLAId] int IDENTITY(1,1) NOT NULL,
    [FundId] int  NOT NULL,
    [SLADocument] varbinary(max)  NULL,
    [FileName] nvarchar(max)  NULL,
    [UploadDate] datetime  NULL,
    [IsActive] bit  NOT NULL,
    [CreatedBy] nvarchar(255)  NULL,
    [DateCreated] datetime  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] nvarchar(255)  NULL
);
GO

-- Creating table 'Language'
CREATE TABLE [dbo].[Language] (
    [LanguagId] char(1)  NOT NULL,
    [LanguageDescription] varchar(100)  NOT NULL
);
GO

-- Creating table 'Map'
CREATE TABLE [dbo].[Map] (
    [mapId] int IDENTITY(1,1) NOT NULL,
    [mapCatagoryId] int  NOT NULL,
    [map1] int  NOT NULL,
    [questionId] int  NOT NULL,
    [questionGroupId] int  NULL,
    [sheetName] nvarchar(50)  NULL
);
GO

-- Creating table 'Member'
CREATE TABLE [dbo].[Member] (
    [MemberId] int IDENTITY(1,1) NOT NULL,
    [EmployerId] int  NULL,
    [MemberNo] varchar(20)  NULL,
    [OtherUniqueMemberNo] varchar(20)  NULL,
    [MemberFirstName] varchar(50)  NULL,
    [MemberOtherName] varchar(50)  NULL,
    [MemberInitial] varchar(5)  NULL,
    [MemberSurname] varchar(50)  NOT NULL,
    [MemberStatusId] int  NOT NULL,
    [LanguageId] char(1)  NOT NULL,
    [EmployeeNo] nvarchar(20)  NULL,
    [IDNo] varchar(13)  NULL,
    [Passport] varchar(15)  NULL,
    [Gender] bit  NULL,
    [DateOfBirth] datetime  NULL,
    [DateJoinedFund] datetime  NULL,
    [DateEmployed] datetime  NULL,
    [NotificationDate] datetime  NULL,
    [ExitDate] datetime  NULL,
    [RemunerationType] char(1)  NULL,
    [IncomeAmount] decimal(19,4)  NULL,
    [FirstContributionDate] datetime  NULL,
    [LastContributionDate] datetime  NULL,
    [ShareOfFundAmount] decimal(19,4)  NULL,
    [HomeLoanAmount] decimal(19,4)  NULL,
    [SARSDirectiveNo] varchar(15)  NULL,
    [EffectivePeriod] varchar(6)  NULL,
    [Validated] bit  NOT NULL,
    [IsValid] bit  NOT NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] nvarchar(255)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] nvarchar(255)  NULL
);
GO

-- Creating table 'MemberClaim'
CREATE TABLE [dbo].[MemberClaim] (
    [MemberClaimId] int IDENTITY(1,1) NOT NULL,
    [MemberId] int  NULL,
    [ClaimNo] varchar(10)  NULL,
    [ClaimTypeId] char(1)  NULL,
    [NotificationDate] datetime  NULL,
    [ExitDate] datetime  NULL,
    [ClaimPaymentStatusId] char(1)  NULL,
    [TotalPaidAmount] decimal(19,4)  NULL,
    [TotalOutstandingAmount] decimal(19,4)  NULL,
    [LastSuccessfulPayDate] datetime  NULL,
    [EffectivePeriod] varchar(6)  NULL,
    [Validated] bit  NOT NULL,
    [IsValid] bit  NOT NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] nvarchar(255)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] nvarchar(255)  NULL
);
GO

-- Creating table 'MemberClaimExceptionLog'
CREATE TABLE [dbo].[MemberClaimExceptionLog] (
    [MemberClaimExceptionLogId] bigint IDENTITY(1,1) NOT NULL,
    [MemberClaimId] int  NOT NULL,
    [ExceptionId] int  NOT NULL,
    [EffectivePeriod] varchar(6)  NOT NULL,
    [RaisedDate] datetime  NOT NULL
);
GO

-- Creating table 'MemberClaimFileData'
CREATE TABLE [dbo].[MemberClaimFileData] (
    [MemberClaimFileDataId] bigint IDENTITY(1,1) NOT NULL,
    [FileLogId] int  NOT NULL,
    [MemberNo] varchar(10)  NULL,
    [ClaimNo] varchar(10)  NULL,
    [ClaimType] varchar(1)  NULL,
    [NotifiedDate] varchar(8)  NULL,
    [ExitDate] varchar(8)  NULL,
    [ClaimPaymentStatus] varchar(1)  NULL,
    [TotalAmountPaid] varchar(15)  NULL,
    [TotalOutstandingAmount] varchar(15)  NULL,
    [LastSuccessfulPaymentDate] varchar(8)  NULL,
    [ImportDateTime] datetime  NOT NULL,
    [HasIssue] bit  NOT NULL
);
GO

-- Creating table 'MemberClaimFileFooter'
CREATE TABLE [dbo].[MemberClaimFileFooter] (
    [MemberClaimFileFooterId] bigint IDENTITY(1,1) NOT NULL,
    [FileLogId] int  NOT NULL,
    [TotalDataRecords] varchar(10)  NULL,
    [SumOfTotalOutstanding] varchar(20)  NULL,
    [ImportDateTime] datetime  NULL,
    [HasIssue] bit  NOT NULL
);
GO

-- Creating table 'MemberClaimFileHeader'
CREATE TABLE [dbo].[MemberClaimFileHeader] (
    [MemberClaimFileHeaderId] bigint IDENTITY(1,1) NOT NULL,
    [FilelogId] int  NOT NULL,
    [FundNo] varchar(8)  NOT NULL,
    [DateFormat] varchar(8)  NOT NULL,
    [FileCreationDate] varchar(8)  NOT NULL,
    [EffectivePeriod] varchar(6)  NOT NULL,
    [ImportDateTime] datetime  NULL,
    [HasIssue] bit  NOT NULL
);
GO

-- Creating table 'MemberExceptionLog'
CREATE TABLE [dbo].[MemberExceptionLog] (
    [MemberExceptionLogId] bigint IDENTITY(1,1) NOT NULL,
    [MemberId] int  NOT NULL,
    [ExceptionId] int  NOT NULL,
    [EffectivePeriod] varchar(6)  NOT NULL,
    [RaisedDate] datetime  NOT NULL
);
GO

-- Creating table 'MemberFileData'
CREATE TABLE [dbo].[MemberFileData] (
    [MemberFileDataId] bigint IDENTITY(1,1) NOT NULL,
    [FileLogId] int  NOT NULL,
    [MemberNo] varchar(10)  NULL,
    [OtherMemberNo] varchar(10)  NULL,
    [MemberFirstName] varchar(50)  NULL,
    [MemberOtherName] varchar(50)  NULL,
    [MemberSurname] varchar(50)  NULL,
    [MemberInitial] varchar(5)  NULL,
    [MemberStatus] varchar(2)  NULL,
    [EmployerNo] varchar(10)  NULL,
    [EmployeeNo] varchar(10)  NULL,
    [IDNo] varchar(13)  NULL,
    [Passport] varchar(13)  NULL,
    [Gender] varchar(1)  NULL,
    [DateOfBirth] varchar(8)  NULL,
    [DateEmployed] varchar(8)  NULL,
    [DateFundJoined] varchar(8)  NULL,
    [NotificationDate] varchar(8)  NULL,
    [ExitDate] varchar(8)  NULL,
    [Language] varchar(1)  NULL,
    [RemunerationType] varchar(1)  NULL,
    [IncomeAmount] varchar(10)  NULL,
    [FirstContributionDate] varchar(8)  NULL,
    [LastContributionDate] varchar(8)  NULL,
    [ShareOfFundAmount] varchar(15)  NULL,
    [HomeLoanAmount] varchar(15)  NULL,
    [SARSDirectiveNo] varchar(15)  NULL,
    [ImportDateTime] datetime  NOT NULL,
    [HasIssue] bit  NOT NULL
);
GO

-- Creating table 'MemberFileFooter'
CREATE TABLE [dbo].[MemberFileFooter] (
    [MemberFileFooterId] bigint IDENTITY(1,1) NOT NULL,
    [FileLogId] int  NOT NULL,
    [TotalDataRecords] varchar(10)  NULL,
    [MemberFundShare] varchar(20)  NULL,
    [ImportDateTime] datetime  NULL,
    [HasIssue] bit  NOT NULL
);
GO

-- Creating table 'MemberFileHeader'
CREATE TABLE [dbo].[MemberFileHeader] (
    [MemberFileHeaderId] bigint IDENTITY(1,1) NOT NULL,
    [FilelogId] int  NOT NULL,
    [FundNo] varchar(8)  NOT NULL,
    [DateFormat] varchar(8)  NOT NULL,
    [FileCreationDate] varchar(8)  NOT NULL,
    [EffectivePeriod] varchar(6)  NOT NULL,
    [ImportDateTime] datetime  NULL,
    [HasIssue] bit  NOT NULL
);
GO

-- Creating table 'MemberPayment'
CREATE TABLE [dbo].[MemberPayment] (
    [MemberPaymentId] int IDENTITY(1,1) NOT NULL,
    [MemberClaimId] int  NULL,
    [PaymentAmount] decimal(19,4)  NULL,
    [PaymentDate] datetime  NULL,
    [PaymentStatusId] char(2)  NULL,
    [FailurePendingReason] varchar(255)  NULL,
    [PaymentMethodId] char(2)  NULL,
    [BankAccountNo] varchar(15)  NULL,
    [BankName] varchar(50)  NULL,
    [BranchNo] varchar(15)  NULL,
    [BranchName] varchar(50)  NULL,
    [BeneficiaryName] varchar(50)  NULL,
    [PaymentTypeId] char(2)  NULL,
    [EffectivePeriod] varchar(6)  NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] nvarchar(255)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] nvarchar(255)  NULL
);
GO

-- Creating table 'MemberPaymentFileData'
CREATE TABLE [dbo].[MemberPaymentFileData] (
    [MemberPaymentFileDataId] bigint IDENTITY(1,1) NOT NULL,
    [FileLogId] int  NOT NULL,
    [MemberNo] varchar(10)  NULL,
    [ClaimNo] varchar(10)  NULL,
    [PaymentAmount] varchar(15)  NULL,
    [PaymentDate] varchar(8)  NULL,
    [PaymentStatus] varchar(2)  NULL,
    [Reason] varchar(100)  NULL,
    [PaymentMethod] varchar(2)  NULL,
    [BankAccountNo] varchar(15)  NULL,
    [BankName] varchar(50)  NULL,
    [BranchNo] varchar(15)  NULL,
    [BranchName] varchar(50)  NULL,
    [BeneficiaryName] varchar(50)  NULL,
    [PaymentType] varchar(2)  NULL,
    [ImportDateTime] datetime  NOT NULL,
    [HasIssue] bit  NOT NULL
);
GO

-- Creating table 'MemberPaymentFileFooter'
CREATE TABLE [dbo].[MemberPaymentFileFooter] (
    [MemberPaymentFileFooterId] bigint IDENTITY(1,1) NOT NULL,
    [FileLogId] int  NOT NULL,
    [TotalDataRecords] varchar(10)  NULL,
    [SumOfSuccessfulPayment] varchar(20)  NULL,
    [ImportDateTime] datetime  NULL,
    [HasIssue] bit  NOT NULL
);
GO

-- Creating table 'MemberPaymentFileHeader'
CREATE TABLE [dbo].[MemberPaymentFileHeader] (
    [MemberPaymentFileHeaderId] bigint IDENTITY(1,1) NOT NULL,
    [FilelogId] int  NOT NULL,
    [FundNo] varchar(8)  NOT NULL,
    [DateFormat] varchar(8)  NOT NULL,
    [FileCreationDate] varchar(8)  NOT NULL,
    [EffectivePeriod] varchar(6)  NOT NULL,
    [ImportDateTime] datetime  NULL,
    [HasIssue] bit  NOT NULL
);
GO

-- Creating table 'MemberStatus'
CREATE TABLE [dbo].[MemberStatus] (
    [MemberStatusId] int  NOT NULL,
    [StatusDescription] varchar(100)  NULL
);
GO

-- Creating table 'MemberTransaction'
CREATE TABLE [dbo].[MemberTransaction] (
    [MemberTransactionId] int IDENTITY(1,1) NOT NULL,
    [MemberId] int  NULL,
    [ContributionDate] datetime  NULL,
    [EmployeeContribution] decimal(19,4)  NULL,
    [EmployeeContributionType] char(1)  NULL,
    [AddVoluntaryContribution] decimal(19,4)  NULL,
    [AddVoluntaryContributionTypeId] char(1)  NULL,
    [EmployerContribution] decimal(19,4)  NULL,
    [EmployerContributionTypeId] char(1)  NULL,
    [EffectivePeriod] varchar(6)  NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] nvarchar(255)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] nvarchar(255)  NULL
);
GO

-- Creating table 'MemberTransactionFileData'
CREATE TABLE [dbo].[MemberTransactionFileData] (
    [MemberTransactionFileDataId] bigint IDENTITY(1,1) NOT NULL,
    [FileLogId] int  NOT NULL,
    [MemberNo] varchar(10)  NULL,
    [ContributionDate] varchar(8)  NULL,
    [EmployeeContribution] varchar(6)  NULL,
    [EmployeeContributionType] varchar(1)  NULL,
    [AddVoluntaryContribution] varchar(6)  NULL,
    [AddVoluntaryContributionType] varchar(1)  NULL,
    [EmployerContribution] varchar(6)  NULL,
    [EmployerContributionType] varchar(1)  NULL,
    [ImportDateTime] datetime  NOT NULL,
    [HasIssue] bit  NOT NULL
);
GO

-- Creating table 'MemberTransactionFileFooter'
CREATE TABLE [dbo].[MemberTransactionFileFooter] (
    [MemberTransactionFileFooterId] bigint IDENTITY(1,1) NOT NULL,
    [FileLogId] int  NOT NULL,
    [TotalDataRecords] varchar(10)  NULL,
    [SumOfEmployerContribution] varchar(20)  NULL,
    [ImportDateTime] datetime  NULL,
    [HasIssue] bit  NOT NULL
);
GO

-- Creating table 'MemberTransactionFileHeader'
CREATE TABLE [dbo].[MemberTransactionFileHeader] (
    [MemberTransactionFileHeaderId] bigint IDENTITY(1,1) NOT NULL,
    [FilelogId] int  NOT NULL,
    [FundNo] varchar(8)  NOT NULL,
    [DateFormat] varchar(8)  NOT NULL,
    [FileCreationDate] varchar(8)  NOT NULL,
    [EffectivePeriod] varchar(6)  NOT NULL,
    [ImportDateTime] datetime  NULL,
    [HasIssue] bit  NOT NULL
);
GO

-- Creating table 'NotificationLog'
CREATE TABLE [dbo].[NotificationLog] (
    [NotificationLogId] int IDENTITY(1,1) NOT NULL,
    [NotificationSentToEmail] nvarchar(255)  NOT NULL,
    [NotificationType] varchar(255)  NOT NULL,
    [SentDateTime] datetime  NOT NULL,
    [InitiatedBy] nvarchar(255)  NOT NULL
);
GO

-- Creating table 'PaymentMethod'
CREATE TABLE [dbo].[PaymentMethod] (
    [PaymentMethodId] char(2)  NOT NULL,
    [PaymentMethodDescription] varchar(100)  NOT NULL
);
GO

-- Creating table 'PaymentStatus'
CREATE TABLE [dbo].[PaymentStatus] (
    [PaymentStatusId] char(2)  NOT NULL,
    [PaymentStatusDescription] varchar(100)  NOT NULL
);
GO

-- Creating table 'PaymentType'
CREATE TABLE [dbo].[PaymentType] (
    [PaymentTypeId] char(2)  NOT NULL,
    [PaymentTypeDescription] varchar(100)  NOT NULL
);
GO

-- Creating table 'Person'
CREATE TABLE [dbo].[Person] (
    [PersonId] int IDENTITY(1,1) NOT NULL,
    [PersonTypeId] int  NOT NULL,
    [TitleId] int  NULL,
    [PositionId] int  NULL,
    [ClientId] int  NULL,
    [EmployerId] int  NULL,
    [Password] nvarchar(50)  NULL,
    [PasswordChangedDate] datetime  NULL,
    [FullName] nvarchar(100)  NOT NULL,
    [IDNumber] varchar(13)  NULL,
    [Email] nvarchar(255)  NOT NULL,
    [Cellphone] varchar(10)  NULL,
    [WorkNo] varchar(10)  NULL,
    [PhysicalAddress] varchar(255)  NULL,
    [PostalAddress] varchar(255)  NULL,
    [Active] bit  NULL,
    [Notify] bit  NULL,
    [IsUser] bit  NULL,
    [FailedPasswordAttemptCount] int  NOT NULL,
    [IsLockedOut] bit  NOT NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] nvarchar(255)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] nvarchar(255)  NULL
);
GO

-- Creating table 'PersonType'
CREATE TABLE [dbo].[PersonType] (
    [PersonTypeId] int  NOT NULL,
    [PersonType1] varchar(50)  NOT NULL
);
GO

-- Creating table 'Position'
CREATE TABLE [dbo].[Position] (
    [PositionId] int  NOT NULL,
    [Position1] varchar(50)  NOT NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] varchar(100)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] varchar(100)  NULL
);
GO

-- Creating table 'Question'
CREATE TABLE [dbo].[Question] (
    [QuestionId] int  NOT NULL,
    [QuestionGroupId] int  NOT NULL,
    [Class] varchar(5)  NOT NULL,
    [Question1] varchar(500)  NOT NULL,
    [AnswerDataTypeId] int  NULL,
    [AnswerFromList] bit  NOT NULL,
    [AnswerMaxLength] int  NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] nvarchar(255)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] nvarchar(255)  NULL,
    [IsGeneral] bit  NULL
);
GO

-- Creating table 'QuestionCategory'
CREATE TABLE [dbo].[QuestionCategory] (
    [QuestionCategoryId] int  NOT NULL,
    [Category] varchar(50)  NULL
);
GO

-- Creating table 'QuestionGroup'
CREATE TABLE [dbo].[QuestionGroup] (
    [QuestionGroupId] int  NOT NULL,
    [QuestionCategoryId] int  NOT NULL,
    [Description] varchar(100)  NOT NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] nvarchar(255)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] nvarchar(255)  NULL
);
GO

-- Creating table 'Reg'
CREATE TABLE [dbo].[Reg] (
    [RegId] int IDENTITY(1,1) NOT NULL,
    [Description] varchar(100)  NOT NULL,
    [GroupId] int  NOT NULL,
    [value] decimal(18,0)  NOT NULL,
    [expression] nvarchar(max)  NULL
);
GO

-- Creating table 'RegGroup'
CREATE TABLE [dbo].[RegGroup] (
    [RegGroupId] int IDENTITY(1,1) NOT NULL,
    [Description] varchar(100)  NOT NULL
);
GO

-- Creating table 'RemunerationType'
CREATE TABLE [dbo].[RemunerationType] (
    [RemunerationTypeId] char(1)  NOT NULL,
    [RemunerationTypeDescription] varchar(100)  NOT NULL
);
GO

-- Creating table 'Title'
CREATE TABLE [dbo].[Title] (
    [TitleId] int  NOT NULL,
    [Title1] varchar(50)  NOT NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] varchar(100)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] varchar(100)  NULL
);
GO

-- Creating table 'uaGroup'
CREATE TABLE [dbo].[uaGroup] (
    [uaGroupId] int IDENTITY(1,1) NOT NULL,
    [GroupName] nvarchar(50)  NOT NULL,
    [CreatedBy] nvarchar(100)  NULL,
    [DateCreated] datetime  NULL,
    [ModifiedBy] nvarchar(100)  NULL,
    [DateModified] datetime  NULL
);
GO

-- Creating table 'uaGroupRole'
CREATE TABLE [dbo].[uaGroupRole] (
    [uaGroupId] int  NOT NULL,
    [uaRoleId] int  NOT NULL,
    [LastUser] varchar(100)  NULL,
    [LastDate] datetime  NULL
);
GO

-- Creating table 'uaRole'
CREATE TABLE [dbo].[uaRole] (
    [uaRoleId] int  NOT NULL,
    [Role] nvarchar(50)  NOT NULL,
    [LastUser] varchar(100)  NULL,
    [LastDate] datetime  NULL
);
GO

-- Creating table 'uaUserFund'
CREATE TABLE [dbo].[uaUserFund] (
    [PersonId] int  NOT NULL,
    [FundId] int  NOT NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] nvarchar(255)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] nvarchar(255)  NULL
);
GO

-- Creating table 'uaUserGroup'
CREATE TABLE [dbo].[uaUserGroup] (
    [PersonId] int  NOT NULL,
    [uaGroupId] int  NOT NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] nvarchar(255)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] nvarchar(255)  NULL
);
GO

-- Creating table 'vw_ActiveQuestionGroup'
CREATE TABLE [dbo].[vw_ActiveQuestionGroup] (
    [QuestionGroupId] int  NOT NULL,
    [Description] varchar(100)  NOT NULL
);
GO

-- Creating table 'vw_aspnet_Applications'
CREATE TABLE [dbo].[vw_aspnet_Applications] (
    [ApplicationName] nvarchar(256)  NOT NULL,
    [LoweredApplicationName] nvarchar(256)  NOT NULL,
    [ApplicationId] uniqueidentifier  NOT NULL,
    [Description] nvarchar(256)  NULL
);
GO

-- Creating table 'vw_aspnet_MembershipUsers'
CREATE TABLE [dbo].[vw_aspnet_MembershipUsers] (
    [UserId] uniqueidentifier  NOT NULL,
    [PasswordFormat] int  NOT NULL,
    [MobilePIN] nvarchar(16)  NULL,
    [Email] nvarchar(256)  NULL,
    [LoweredEmail] nvarchar(256)  NULL,
    [PasswordQuestion] nvarchar(256)  NULL,
    [PasswordAnswer] nvarchar(128)  NULL,
    [IsApproved] bit  NOT NULL,
    [IsLockedOut] bit  NOT NULL,
    [CreateDate] datetime  NOT NULL,
    [LastLoginDate] datetime  NOT NULL,
    [LastPasswordChangedDate] datetime  NOT NULL,
    [LastLockoutDate] datetime  NOT NULL,
    [FailedPasswordAttemptCount] int  NOT NULL,
    [FailedPasswordAttemptWindowStart] datetime  NOT NULL,
    [FailedPasswordAnswerAttemptCount] int  NOT NULL,
    [FailedPasswordAnswerAttemptWindowStart] datetime  NOT NULL,
    [Comment] nvarchar(max)  NULL,
    [ApplicationId] uniqueidentifier  NOT NULL,
    [UserName] nvarchar(256)  NOT NULL,
    [MobileAlias] nvarchar(16)  NULL,
    [IsAnonymous] bit  NOT NULL,
    [LastActivityDate] datetime  NOT NULL
);
GO

-- Creating table 'vw_aspnet_Profiles'
CREATE TABLE [dbo].[vw_aspnet_Profiles] (
    [UserId] uniqueidentifier  NOT NULL,
    [LastUpdatedDate] datetime  NOT NULL,
    [DataSize] int  NULL
);
GO

-- Creating table 'vw_aspnet_Roles'
CREATE TABLE [dbo].[vw_aspnet_Roles] (
    [ApplicationId] uniqueidentifier  NOT NULL,
    [RoleId] uniqueidentifier  NOT NULL,
    [RoleName] nvarchar(256)  NOT NULL,
    [LoweredRoleName] nvarchar(256)  NOT NULL,
    [Description] nvarchar(256)  NULL
);
GO

-- Creating table 'vw_aspnet_Users'
CREATE TABLE [dbo].[vw_aspnet_Users] (
    [ApplicationId] uniqueidentifier  NOT NULL,
    [UserId] uniqueidentifier  NOT NULL,
    [UserName] nvarchar(256)  NOT NULL,
    [LoweredUserName] nvarchar(256)  NOT NULL,
    [MobileAlias] nvarchar(16)  NULL,
    [IsAnonymous] bit  NOT NULL,
    [LastActivityDate] datetime  NOT NULL
);
GO

-- Creating table 'vw_aspnet_UsersInRoles'
CREATE TABLE [dbo].[vw_aspnet_UsersInRoles] (
    [UserId] uniqueidentifier  NOT NULL,
    [RoleId] uniqueidentifier  NOT NULL
);
GO

-- Creating table 'vw_aspnet_WebPartState_Paths'
CREATE TABLE [dbo].[vw_aspnet_WebPartState_Paths] (
    [ApplicationId] uniqueidentifier  NOT NULL,
    [PathId] uniqueidentifier  NOT NULL,
    [Path] nvarchar(256)  NOT NULL,
    [LoweredPath] nvarchar(256)  NOT NULL
);
GO

-- Creating table 'vw_aspnet_WebPartState_Shared'
CREATE TABLE [dbo].[vw_aspnet_WebPartState_Shared] (
    [PathId] uniqueidentifier  NOT NULL,
    [DataSize] int  NULL,
    [LastUpdatedDate] datetime  NOT NULL
);
GO

-- Creating table 'vw_aspnet_WebPartState_User'
CREATE TABLE [dbo].[vw_aspnet_WebPartState_User] (
    [PathId] uniqueidentifier  NULL,
    [UserId] uniqueidentifier  NULL,
    [DataSize] int  NULL,
    [LastUpdatedDate] datetime  NOT NULL
);
GO

-- Creating table 'vw_ElectionPeriods'
CREATE TABLE [dbo].[vw_ElectionPeriods] (
    [FundId] int  NOT NULL,
    [ElectionPeriod] varchar(63)  NULL,
    [FundElectedPeriodId] int IDENTITY(1,1) NOT NULL
);
GO

-- Creating table 'vw_FundAdministratorFund'
CREATE TABLE [dbo].[vw_FundAdministratorFund] (
    [FundId] int  NOT NULL,
    [FundNo] nvarchar(20)  NOT NULL,
    [ClientId] int  NOT NULL,
    [FundName] varchar(50)  NOT NULL,
    [EffectiveDate] datetime  NOT NULL,
    [ValidMonths] int  NOT NULL,
    [EndDate] datetime  NOT NULL,
    [PhysicalAddress] varchar(255)  NULL,
    [PostalAddress] varchar(255)  NULL,
    [Active] bit  NULL,
    [Logo] varbinary(max)  NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] varchar(100)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] varchar(100)  NULL,
    [PersonId] int  NOT NULL,
    [Email] nvarchar(255)  NOT NULL
);
GO

-- Creating table 'vw_FundAdministratorUsers'
CREATE TABLE [dbo].[vw_FundAdministratorUsers] (
    [PersonId] int  NOT NULL,
    [FullName] nvarchar(100)  NOT NULL,
    [Active] bit  NULL
);
GO

-- Creating table 'vw_SystemUsers'
CREATE TABLE [dbo].[vw_SystemUsers] (
    [PersonId] int IDENTITY(1,1) NOT NULL,
    [FullName] nvarchar(100)  NOT NULL,
    [Active] bit  NULL
);
GO

-- Creating table 'vw_TrusteeFund'
CREATE TABLE [dbo].[vw_TrusteeFund] (
    [TrusteeId] int  NOT NULL,
    [Email] nvarchar(255)  NOT NULL,
    [FundId] int  NOT NULL,
    [FundNo] nvarchar(20)  NOT NULL,
    [ClientId] int  NOT NULL,
    [FundName] varchar(50)  NOT NULL,
    [EffectiveDate] datetime  NOT NULL,
    [ValidMonths] int  NOT NULL,
    [EndDate] datetime  NOT NULL,
    [PhysicalAddress] varchar(255)  NULL,
    [PostalAddress] varchar(255)  NULL,
    [Active] bit  NULL,
    [Logo] varbinary(max)  NULL,
    [DateCreated] datetime  NULL,
    [CreatedBy] varchar(100)  NULL,
    [DateModified] datetime  NULL,
    [ModifiedBy] varchar(100)  NULL
);
GO

-- Creating table 'aspnet_UsersInRoles'
CREATE TABLE [dbo].[aspnet_UsersInRoles] (
    [aspnet_Roles_RoleId] uniqueidentifier  NOT NULL,
    [aspnet_Users_UserId] uniqueidentifier  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [AuditFundAnswerSheetId] in table 'AuditFundAnswerSheet'
ALTER TABLE [dbo].[AuditFundAnswerSheet]
ADD CONSTRAINT [PK_AuditFundAnswerSheet]
    PRIMARY KEY CLUSTERED ([AuditFundAnswerSheetId] ASC);
GO

-- Creating primary key on [AuditPersonId] in table 'AuditPerson'
ALTER TABLE [dbo].[AuditPerson]
ADD CONSTRAINT [PK_AuditPerson]
    PRIMARY KEY CLUSTERED ([AuditPersonId] ASC);
GO

-- Creating primary key on [AnswerDataTypeId] in table 'AnswerDataType'
ALTER TABLE [dbo].[AnswerDataType]
ADD CONSTRAINT [PK_AnswerDataType]
    PRIMARY KEY CLUSTERED ([AnswerDataTypeId] ASC);
GO

-- Creating primary key on [AnswerOptionId] in table 'AnswerOption'
ALTER TABLE [dbo].[AnswerOption]
ADD CONSTRAINT [PK_AnswerOption]
    PRIMARY KEY CLUSTERED ([AnswerOptionId] ASC);
GO

-- Creating primary key on [ApplicationId] in table 'aspnet_Applications'
ALTER TABLE [dbo].[aspnet_Applications]
ADD CONSTRAINT [PK_aspnet_Applications]
    PRIMARY KEY CLUSTERED ([ApplicationId] ASC);
GO

-- Creating primary key on [UserId] in table 'aspnet_Membership'
ALTER TABLE [dbo].[aspnet_Membership]
ADD CONSTRAINT [PK_aspnet_Membership]
    PRIMARY KEY CLUSTERED ([UserId] ASC);
GO

-- Creating primary key on [PathId] in table 'aspnet_Paths'
ALTER TABLE [dbo].[aspnet_Paths]
ADD CONSTRAINT [PK_aspnet_Paths]
    PRIMARY KEY CLUSTERED ([PathId] ASC);
GO

-- Creating primary key on [PathId] in table 'aspnet_PersonalizationAllUsers'
ALTER TABLE [dbo].[aspnet_PersonalizationAllUsers]
ADD CONSTRAINT [PK_aspnet_PersonalizationAllUsers]
    PRIMARY KEY CLUSTERED ([PathId] ASC);
GO

-- Creating primary key on [Id] in table 'aspnet_PersonalizationPerUser'
ALTER TABLE [dbo].[aspnet_PersonalizationPerUser]
ADD CONSTRAINT [PK_aspnet_PersonalizationPerUser]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [UserId] in table 'aspnet_Profile'
ALTER TABLE [dbo].[aspnet_Profile]
ADD CONSTRAINT [PK_aspnet_Profile]
    PRIMARY KEY CLUSTERED ([UserId] ASC);
GO

-- Creating primary key on [RoleId] in table 'aspnet_Roles'
ALTER TABLE [dbo].[aspnet_Roles]
ADD CONSTRAINT [PK_aspnet_Roles]
    PRIMARY KEY CLUSTERED ([RoleId] ASC);
GO

-- Creating primary key on [Feature], [CompatibleSchemaVersion] in table 'aspnet_SchemaVersions'
ALTER TABLE [dbo].[aspnet_SchemaVersions]
ADD CONSTRAINT [PK_aspnet_SchemaVersions]
    PRIMARY KEY CLUSTERED ([Feature], [CompatibleSchemaVersion] ASC);
GO

-- Creating primary key on [UserId] in table 'aspnet_Users'
ALTER TABLE [dbo].[aspnet_Users]
ADD CONSTRAINT [PK_aspnet_Users]
    PRIMARY KEY CLUSTERED ([UserId] ASC);
GO

-- Creating primary key on [EventId] in table 'aspnet_WebEvent_Events'
ALTER TABLE [dbo].[aspnet_WebEvent_Events]
ADD CONSTRAINT [PK_aspnet_WebEvent_Events]
    PRIMARY KEY CLUSTERED ([EventId] ASC);
GO

-- Creating primary key on [ClaimPaymentStatusId] in table 'ClaimPaymentStatus'
ALTER TABLE [dbo].[ClaimPaymentStatus]
ADD CONSTRAINT [PK_ClaimPaymentStatus]
    PRIMARY KEY CLUSTERED ([ClaimPaymentStatusId] ASC);
GO

-- Creating primary key on [ClaimTypeId] in table 'ClaimType'
ALTER TABLE [dbo].[ClaimType]
ADD CONSTRAINT [PK_ClaimType]
    PRIMARY KEY CLUSTERED ([ClaimTypeId] ASC);
GO

-- Creating primary key on [ClientId] in table 'Client'
ALTER TABLE [dbo].[Client]
ADD CONSTRAINT [PK_Client]
    PRIMARY KEY CLUSTERED ([ClientId] ASC);
GO

-- Creating primary key on [ContributionTypeId] in table 'ContributionType'
ALTER TABLE [dbo].[ContributionType]
ADD CONSTRAINT [PK_ContributionType]
    PRIMARY KEY CLUSTERED ([ContributionTypeId] ASC);
GO

-- Creating primary key on [EmployerId] in table 'Employer'
ALTER TABLE [dbo].[Employer]
ADD CONSTRAINT [PK_Employer]
    PRIMARY KEY CLUSTERED ([EmployerId] ASC);
GO

-- Creating primary key on [EmployerFileDataId] in table 'EmployerFileData'
ALTER TABLE [dbo].[EmployerFileData]
ADD CONSTRAINT [PK_EmployerFileData]
    PRIMARY KEY CLUSTERED ([EmployerFileDataId] ASC);
GO

-- Creating primary key on [EmployerFileFooterId] in table 'EmployerFileFooter'
ALTER TABLE [dbo].[EmployerFileFooter]
ADD CONSTRAINT [PK_EmployerFileFooter]
    PRIMARY KEY CLUSTERED ([EmployerFileFooterId] ASC);
GO

-- Creating primary key on [EmployerFileHeaderId] in table 'EmployerFileHeader'
ALTER TABLE [dbo].[EmployerFileHeader]
ADD CONSTRAINT [PK_EmployerFileHeader]
    PRIMARY KEY CLUSTERED ([EmployerFileHeaderId] ASC);
GO

-- Creating primary key on [EmployerStatusId] in table 'EmployerStatus'
ALTER TABLE [dbo].[EmployerStatus]
ADD CONSTRAINT [PK_EmployerStatus]
    PRIMARY KEY CLUSTERED ([EmployerStatusId] ASC);
GO

-- Creating primary key on [ExceptionId] in table 'Exception'
ALTER TABLE [dbo].[Exception]
ADD CONSTRAINT [PK_Exception]
    PRIMARY KEY CLUSTERED ([ExceptionId] ASC);
GO

-- Creating primary key on [FileExceptionlogId] in table 'FileExceptionLog'
ALTER TABLE [dbo].[FileExceptionLog]
ADD CONSTRAINT [PK_FileExceptionLog]
    PRIMARY KEY CLUSTERED ([FileExceptionlogId] ASC);
GO

-- Creating primary key on [FileImportTypeId] in table 'FileImportType'
ALTER TABLE [dbo].[FileImportType]
ADD CONSTRAINT [PK_FileImportType]
    PRIMARY KEY CLUSTERED ([FileImportTypeId] ASC);
GO

-- Creating primary key on [FileLogId] in table 'FileLog'
ALTER TABLE [dbo].[FileLog]
ADD CONSTRAINT [PK_FileLog]
    PRIMARY KEY CLUSTERED ([FileLogId] ASC);
GO

-- Creating primary key on [FileProcessStatusId] in table 'FileProcessStatus'
ALTER TABLE [dbo].[FileProcessStatus]
ADD CONSTRAINT [PK_FileProcessStatus]
    PRIMARY KEY CLUSTERED ([FileProcessStatusId] ASC);
GO

-- Creating primary key on [FundId] in table 'Fund'
ALTER TABLE [dbo].[Fund]
ADD CONSTRAINT [PK_Fund]
    PRIMARY KEY CLUSTERED ([FundId] ASC);
GO

-- Creating primary key on [FundAnswerSheetId] in table 'FundAnswerSheet'
ALTER TABLE [dbo].[FundAnswerSheet]
ADD CONSTRAINT [PK_FundAnswerSheet]
    PRIMARY KEY CLUSTERED ([FundAnswerSheetId] ASC);
GO

-- Creating primary key on [FundElectedPeriodId] in table 'FundElectedPeriod'
ALTER TABLE [dbo].[FundElectedPeriod]
ADD CONSTRAINT [PK_FundElectedPeriod]
    PRIMARY KEY CLUSTERED ([FundElectedPeriodId] ASC);
GO

-- Creating primary key on [FundElectedPeriodId], [TrusteeId] in table 'FundElectedPeriodTrustee'
ALTER TABLE [dbo].[FundElectedPeriodTrustee]
ADD CONSTRAINT [PK_FundElectedPeriodTrustee]
    PRIMARY KEY CLUSTERED ([FundElectedPeriodId], [TrusteeId] ASC);
GO

-- Creating primary key on [FundSLAId] in table 'FundSLA'
ALTER TABLE [dbo].[FundSLA]
ADD CONSTRAINT [PK_FundSLA]
    PRIMARY KEY CLUSTERED ([FundSLAId] ASC);
GO

-- Creating primary key on [LanguagId] in table 'Language'
ALTER TABLE [dbo].[Language]
ADD CONSTRAINT [PK_Language]
    PRIMARY KEY CLUSTERED ([LanguagId] ASC);
GO

-- Creating primary key on [mapId] in table 'Map'
ALTER TABLE [dbo].[Map]
ADD CONSTRAINT [PK_Map]
    PRIMARY KEY CLUSTERED ([mapId] ASC);
GO

-- Creating primary key on [MemberId] in table 'Member'
ALTER TABLE [dbo].[Member]
ADD CONSTRAINT [PK_Member]
    PRIMARY KEY CLUSTERED ([MemberId] ASC);
GO

-- Creating primary key on [MemberClaimId] in table 'MemberClaim'
ALTER TABLE [dbo].[MemberClaim]
ADD CONSTRAINT [PK_MemberClaim]
    PRIMARY KEY CLUSTERED ([MemberClaimId] ASC);
GO

-- Creating primary key on [MemberClaimExceptionLogId] in table 'MemberClaimExceptionLog'
ALTER TABLE [dbo].[MemberClaimExceptionLog]
ADD CONSTRAINT [PK_MemberClaimExceptionLog]
    PRIMARY KEY CLUSTERED ([MemberClaimExceptionLogId] ASC);
GO

-- Creating primary key on [MemberClaimFileDataId] in table 'MemberClaimFileData'
ALTER TABLE [dbo].[MemberClaimFileData]
ADD CONSTRAINT [PK_MemberClaimFileData]
    PRIMARY KEY CLUSTERED ([MemberClaimFileDataId] ASC);
GO

-- Creating primary key on [MemberClaimFileFooterId] in table 'MemberClaimFileFooter'
ALTER TABLE [dbo].[MemberClaimFileFooter]
ADD CONSTRAINT [PK_MemberClaimFileFooter]
    PRIMARY KEY CLUSTERED ([MemberClaimFileFooterId] ASC);
GO

-- Creating primary key on [MemberClaimFileHeaderId] in table 'MemberClaimFileHeader'
ALTER TABLE [dbo].[MemberClaimFileHeader]
ADD CONSTRAINT [PK_MemberClaimFileHeader]
    PRIMARY KEY CLUSTERED ([MemberClaimFileHeaderId] ASC);
GO

-- Creating primary key on [MemberExceptionLogId] in table 'MemberExceptionLog'
ALTER TABLE [dbo].[MemberExceptionLog]
ADD CONSTRAINT [PK_MemberExceptionLog]
    PRIMARY KEY CLUSTERED ([MemberExceptionLogId] ASC);
GO

-- Creating primary key on [MemberFileDataId] in table 'MemberFileData'
ALTER TABLE [dbo].[MemberFileData]
ADD CONSTRAINT [PK_MemberFileData]
    PRIMARY KEY CLUSTERED ([MemberFileDataId] ASC);
GO

-- Creating primary key on [MemberFileFooterId] in table 'MemberFileFooter'
ALTER TABLE [dbo].[MemberFileFooter]
ADD CONSTRAINT [PK_MemberFileFooter]
    PRIMARY KEY CLUSTERED ([MemberFileFooterId] ASC);
GO

-- Creating primary key on [MemberFileHeaderId] in table 'MemberFileHeader'
ALTER TABLE [dbo].[MemberFileHeader]
ADD CONSTRAINT [PK_MemberFileHeader]
    PRIMARY KEY CLUSTERED ([MemberFileHeaderId] ASC);
GO

-- Creating primary key on [MemberPaymentId] in table 'MemberPayment'
ALTER TABLE [dbo].[MemberPayment]
ADD CONSTRAINT [PK_MemberPayment]
    PRIMARY KEY CLUSTERED ([MemberPaymentId] ASC);
GO

-- Creating primary key on [MemberPaymentFileDataId] in table 'MemberPaymentFileData'
ALTER TABLE [dbo].[MemberPaymentFileData]
ADD CONSTRAINT [PK_MemberPaymentFileData]
    PRIMARY KEY CLUSTERED ([MemberPaymentFileDataId] ASC);
GO

-- Creating primary key on [MemberPaymentFileFooterId] in table 'MemberPaymentFileFooter'
ALTER TABLE [dbo].[MemberPaymentFileFooter]
ADD CONSTRAINT [PK_MemberPaymentFileFooter]
    PRIMARY KEY CLUSTERED ([MemberPaymentFileFooterId] ASC);
GO

-- Creating primary key on [MemberPaymentFileHeaderId] in table 'MemberPaymentFileHeader'
ALTER TABLE [dbo].[MemberPaymentFileHeader]
ADD CONSTRAINT [PK_MemberPaymentFileHeader]
    PRIMARY KEY CLUSTERED ([MemberPaymentFileHeaderId] ASC);
GO

-- Creating primary key on [MemberStatusId] in table 'MemberStatus'
ALTER TABLE [dbo].[MemberStatus]
ADD CONSTRAINT [PK_MemberStatus]
    PRIMARY KEY CLUSTERED ([MemberStatusId] ASC);
GO

-- Creating primary key on [MemberTransactionId] in table 'MemberTransaction'
ALTER TABLE [dbo].[MemberTransaction]
ADD CONSTRAINT [PK_MemberTransaction]
    PRIMARY KEY CLUSTERED ([MemberTransactionId] ASC);
GO

-- Creating primary key on [MemberTransactionFileDataId] in table 'MemberTransactionFileData'
ALTER TABLE [dbo].[MemberTransactionFileData]
ADD CONSTRAINT [PK_MemberTransactionFileData]
    PRIMARY KEY CLUSTERED ([MemberTransactionFileDataId] ASC);
GO

-- Creating primary key on [MemberTransactionFileFooterId] in table 'MemberTransactionFileFooter'
ALTER TABLE [dbo].[MemberTransactionFileFooter]
ADD CONSTRAINT [PK_MemberTransactionFileFooter]
    PRIMARY KEY CLUSTERED ([MemberTransactionFileFooterId] ASC);
GO

-- Creating primary key on [MemberTransactionFileHeaderId] in table 'MemberTransactionFileHeader'
ALTER TABLE [dbo].[MemberTransactionFileHeader]
ADD CONSTRAINT [PK_MemberTransactionFileHeader]
    PRIMARY KEY CLUSTERED ([MemberTransactionFileHeaderId] ASC);
GO

-- Creating primary key on [NotificationLogId] in table 'NotificationLog'
ALTER TABLE [dbo].[NotificationLog]
ADD CONSTRAINT [PK_NotificationLog]
    PRIMARY KEY CLUSTERED ([NotificationLogId] ASC);
GO

-- Creating primary key on [PaymentMethodId] in table 'PaymentMethod'
ALTER TABLE [dbo].[PaymentMethod]
ADD CONSTRAINT [PK_PaymentMethod]
    PRIMARY KEY CLUSTERED ([PaymentMethodId] ASC);
GO

-- Creating primary key on [PaymentStatusId] in table 'PaymentStatus'
ALTER TABLE [dbo].[PaymentStatus]
ADD CONSTRAINT [PK_PaymentStatus]
    PRIMARY KEY CLUSTERED ([PaymentStatusId] ASC);
GO

-- Creating primary key on [PaymentTypeId] in table 'PaymentType'
ALTER TABLE [dbo].[PaymentType]
ADD CONSTRAINT [PK_PaymentType]
    PRIMARY KEY CLUSTERED ([PaymentTypeId] ASC);
GO

-- Creating primary key on [PersonId] in table 'Person'
ALTER TABLE [dbo].[Person]
ADD CONSTRAINT [PK_Person]
    PRIMARY KEY CLUSTERED ([PersonId] ASC);
GO

-- Creating primary key on [PersonTypeId] in table 'PersonType'
ALTER TABLE [dbo].[PersonType]
ADD CONSTRAINT [PK_PersonType]
    PRIMARY KEY CLUSTERED ([PersonTypeId] ASC);
GO

-- Creating primary key on [PositionId] in table 'Position'
ALTER TABLE [dbo].[Position]
ADD CONSTRAINT [PK_Position]
    PRIMARY KEY CLUSTERED ([PositionId] ASC);
GO

-- Creating primary key on [QuestionId] in table 'Question'
ALTER TABLE [dbo].[Question]
ADD CONSTRAINT [PK_Question]
    PRIMARY KEY CLUSTERED ([QuestionId] ASC);
GO

-- Creating primary key on [QuestionCategoryId] in table 'QuestionCategory'
ALTER TABLE [dbo].[QuestionCategory]
ADD CONSTRAINT [PK_QuestionCategory]
    PRIMARY KEY CLUSTERED ([QuestionCategoryId] ASC);
GO

-- Creating primary key on [QuestionGroupId] in table 'QuestionGroup'
ALTER TABLE [dbo].[QuestionGroup]
ADD CONSTRAINT [PK_QuestionGroup]
    PRIMARY KEY CLUSTERED ([QuestionGroupId] ASC);
GO

-- Creating primary key on [RegId] in table 'Reg'
ALTER TABLE [dbo].[Reg]
ADD CONSTRAINT [PK_Reg]
    PRIMARY KEY CLUSTERED ([RegId] ASC);
GO

-- Creating primary key on [RegGroupId] in table 'RegGroup'
ALTER TABLE [dbo].[RegGroup]
ADD CONSTRAINT [PK_RegGroup]
    PRIMARY KEY CLUSTERED ([RegGroupId] ASC);
GO

-- Creating primary key on [RemunerationTypeId] in table 'RemunerationType'
ALTER TABLE [dbo].[RemunerationType]
ADD CONSTRAINT [PK_RemunerationType]
    PRIMARY KEY CLUSTERED ([RemunerationTypeId] ASC);
GO

-- Creating primary key on [TitleId] in table 'Title'
ALTER TABLE [dbo].[Title]
ADD CONSTRAINT [PK_Title]
    PRIMARY KEY CLUSTERED ([TitleId] ASC);
GO

-- Creating primary key on [uaGroupId] in table 'uaGroup'
ALTER TABLE [dbo].[uaGroup]
ADD CONSTRAINT [PK_uaGroup]
    PRIMARY KEY CLUSTERED ([uaGroupId] ASC);
GO

-- Creating primary key on [uaGroupId], [uaRoleId] in table 'uaGroupRole'
ALTER TABLE [dbo].[uaGroupRole]
ADD CONSTRAINT [PK_uaGroupRole]
    PRIMARY KEY CLUSTERED ([uaGroupId], [uaRoleId] ASC);
GO

-- Creating primary key on [uaRoleId] in table 'uaRole'
ALTER TABLE [dbo].[uaRole]
ADD CONSTRAINT [PK_uaRole]
    PRIMARY KEY CLUSTERED ([uaRoleId] ASC);
GO

-- Creating primary key on [PersonId], [FundId] in table 'uaUserFund'
ALTER TABLE [dbo].[uaUserFund]
ADD CONSTRAINT [PK_uaUserFund]
    PRIMARY KEY CLUSTERED ([PersonId], [FundId] ASC);
GO

-- Creating primary key on [PersonId], [uaGroupId] in table 'uaUserGroup'
ALTER TABLE [dbo].[uaUserGroup]
ADD CONSTRAINT [PK_uaUserGroup]
    PRIMARY KEY CLUSTERED ([PersonId], [uaGroupId] ASC);
GO

-- Creating primary key on [QuestionGroupId], [Description] in table 'vw_ActiveQuestionGroup'
ALTER TABLE [dbo].[vw_ActiveQuestionGroup]
ADD CONSTRAINT [PK_vw_ActiveQuestionGroup]
    PRIMARY KEY CLUSTERED ([QuestionGroupId], [Description] ASC);
GO

-- Creating primary key on [ApplicationName], [LoweredApplicationName], [ApplicationId] in table 'vw_aspnet_Applications'
ALTER TABLE [dbo].[vw_aspnet_Applications]
ADD CONSTRAINT [PK_vw_aspnet_Applications]
    PRIMARY KEY CLUSTERED ([ApplicationName], [LoweredApplicationName], [ApplicationId] ASC);
GO

-- Creating primary key on [UserId], [PasswordFormat], [IsApproved], [IsLockedOut], [CreateDate], [LastLoginDate], [LastPasswordChangedDate], [LastLockoutDate], [FailedPasswordAttemptCount], [FailedPasswordAttemptWindowStart], [FailedPasswordAnswerAttemptCount], [FailedPasswordAnswerAttemptWindowStart], [ApplicationId], [UserName], [IsAnonymous], [LastActivityDate] in table 'vw_aspnet_MembershipUsers'
ALTER TABLE [dbo].[vw_aspnet_MembershipUsers]
ADD CONSTRAINT [PK_vw_aspnet_MembershipUsers]
    PRIMARY KEY CLUSTERED ([UserId], [PasswordFormat], [IsApproved], [IsLockedOut], [CreateDate], [LastLoginDate], [LastPasswordChangedDate], [LastLockoutDate], [FailedPasswordAttemptCount], [FailedPasswordAttemptWindowStart], [FailedPasswordAnswerAttemptCount], [FailedPasswordAnswerAttemptWindowStart], [ApplicationId], [UserName], [IsAnonymous], [LastActivityDate] ASC);
GO

-- Creating primary key on [UserId], [LastUpdatedDate] in table 'vw_aspnet_Profiles'
ALTER TABLE [dbo].[vw_aspnet_Profiles]
ADD CONSTRAINT [PK_vw_aspnet_Profiles]
    PRIMARY KEY CLUSTERED ([UserId], [LastUpdatedDate] ASC);
GO

-- Creating primary key on [ApplicationId], [RoleId], [RoleName], [LoweredRoleName] in table 'vw_aspnet_Roles'
ALTER TABLE [dbo].[vw_aspnet_Roles]
ADD CONSTRAINT [PK_vw_aspnet_Roles]
    PRIMARY KEY CLUSTERED ([ApplicationId], [RoleId], [RoleName], [LoweredRoleName] ASC);
GO

-- Creating primary key on [ApplicationId], [UserId], [UserName], [LoweredUserName], [IsAnonymous], [LastActivityDate] in table 'vw_aspnet_Users'
ALTER TABLE [dbo].[vw_aspnet_Users]
ADD CONSTRAINT [PK_vw_aspnet_Users]
    PRIMARY KEY CLUSTERED ([ApplicationId], [UserId], [UserName], [LoweredUserName], [IsAnonymous], [LastActivityDate] ASC);
GO

-- Creating primary key on [UserId], [RoleId] in table 'vw_aspnet_UsersInRoles'
ALTER TABLE [dbo].[vw_aspnet_UsersInRoles]
ADD CONSTRAINT [PK_vw_aspnet_UsersInRoles]
    PRIMARY KEY CLUSTERED ([UserId], [RoleId] ASC);
GO

-- Creating primary key on [ApplicationId], [PathId], [Path], [LoweredPath] in table 'vw_aspnet_WebPartState_Paths'
ALTER TABLE [dbo].[vw_aspnet_WebPartState_Paths]
ADD CONSTRAINT [PK_vw_aspnet_WebPartState_Paths]
    PRIMARY KEY CLUSTERED ([ApplicationId], [PathId], [Path], [LoweredPath] ASC);
GO

-- Creating primary key on [PathId], [LastUpdatedDate] in table 'vw_aspnet_WebPartState_Shared'
ALTER TABLE [dbo].[vw_aspnet_WebPartState_Shared]
ADD CONSTRAINT [PK_vw_aspnet_WebPartState_Shared]
    PRIMARY KEY CLUSTERED ([PathId], [LastUpdatedDate] ASC);
GO

-- Creating primary key on [LastUpdatedDate] in table 'vw_aspnet_WebPartState_User'
ALTER TABLE [dbo].[vw_aspnet_WebPartState_User]
ADD CONSTRAINT [PK_vw_aspnet_WebPartState_User]
    PRIMARY KEY CLUSTERED ([LastUpdatedDate] ASC);
GO

-- Creating primary key on [FundId], [FundElectedPeriodId] in table 'vw_ElectionPeriods'
ALTER TABLE [dbo].[vw_ElectionPeriods]
ADD CONSTRAINT [PK_vw_ElectionPeriods]
    PRIMARY KEY CLUSTERED ([FundId], [FundElectedPeriodId] ASC);
GO

-- Creating primary key on [FundId], [FundNo], [ClientId], [FundName], [EffectiveDate], [ValidMonths], [EndDate], [PersonId], [Email] in table 'vw_FundAdministratorFund'
ALTER TABLE [dbo].[vw_FundAdministratorFund]
ADD CONSTRAINT [PK_vw_FundAdministratorFund]
    PRIMARY KEY CLUSTERED ([FundId], [FundNo], [ClientId], [FundName], [EffectiveDate], [ValidMonths], [EndDate], [PersonId], [Email] ASC);
GO

-- Creating primary key on [PersonId], [FullName] in table 'vw_FundAdministratorUsers'
ALTER TABLE [dbo].[vw_FundAdministratorUsers]
ADD CONSTRAINT [PK_vw_FundAdministratorUsers]
    PRIMARY KEY CLUSTERED ([PersonId], [FullName] ASC);
GO

-- Creating primary key on [PersonId], [FullName] in table 'vw_SystemUsers'
ALTER TABLE [dbo].[vw_SystemUsers]
ADD CONSTRAINT [PK_vw_SystemUsers]
    PRIMARY KEY CLUSTERED ([PersonId], [FullName] ASC);
GO

-- Creating primary key on [TrusteeId], [Email], [FundId], [FundNo], [ClientId], [FundName], [EffectiveDate], [ValidMonths], [EndDate] in table 'vw_TrusteeFund'
ALTER TABLE [dbo].[vw_TrusteeFund]
ADD CONSTRAINT [PK_vw_TrusteeFund]
    PRIMARY KEY CLUSTERED ([TrusteeId], [Email], [FundId], [FundNo], [ClientId], [FundName], [EffectiveDate], [ValidMonths], [EndDate] ASC);
GO

-- Creating primary key on [aspnet_Roles_RoleId], [aspnet_Users_UserId] in table 'aspnet_UsersInRoles'
ALTER TABLE [dbo].[aspnet_UsersInRoles]
ADD CONSTRAINT [PK_aspnet_UsersInRoles]
    PRIMARY KEY NONCLUSTERED ([aspnet_Roles_RoleId], [aspnet_Users_UserId] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [AnswerDataTypeId] in table 'Question'
ALTER TABLE [dbo].[Question]
ADD CONSTRAINT [FK_Question_AnswerDataType]
    FOREIGN KEY ([AnswerDataTypeId])
    REFERENCES [dbo].[AnswerDataType]
        ([AnswerDataTypeId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Question_AnswerDataType'
CREATE INDEX [IX_FK_Question_AnswerDataType]
ON [dbo].[Question]
    ([AnswerDataTypeId]);
GO

-- Creating foreign key on [QuestionId] in table 'AnswerOption'
ALTER TABLE [dbo].[AnswerOption]
ADD CONSTRAINT [FK_AnswerOption_Question]
    FOREIGN KEY ([QuestionId])
    REFERENCES [dbo].[Question]
        ([QuestionId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_AnswerOption_Question'
CREATE INDEX [IX_FK_AnswerOption_Question]
ON [dbo].[AnswerOption]
    ([QuestionId]);
GO

-- Creating foreign key on [ApplicationId] in table 'aspnet_Membership'
ALTER TABLE [dbo].[aspnet_Membership]
ADD CONSTRAINT [FK__aspnet_Me__Appli__68D28DBC]
    FOREIGN KEY ([ApplicationId])
    REFERENCES [dbo].[aspnet_Applications]
        ([ApplicationId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK__aspnet_Me__Appli__68D28DBC'
CREATE INDEX [IX_FK__aspnet_Me__Appli__68D28DBC]
ON [dbo].[aspnet_Membership]
    ([ApplicationId]);
GO

-- Creating foreign key on [ApplicationId] in table 'aspnet_Paths'
ALTER TABLE [dbo].[aspnet_Paths]
ADD CONSTRAINT [FK__aspnet_Pa__Appli__1A69E950]
    FOREIGN KEY ([ApplicationId])
    REFERENCES [dbo].[aspnet_Applications]
        ([ApplicationId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK__aspnet_Pa__Appli__1A69E950'
CREATE INDEX [IX_FK__aspnet_Pa__Appli__1A69E950]
ON [dbo].[aspnet_Paths]
    ([ApplicationId]);
GO

-- Creating foreign key on [ApplicationId] in table 'aspnet_Roles'
ALTER TABLE [dbo].[aspnet_Roles]
ADD CONSTRAINT [FK__aspnet_Ro__Appli__075714DC]
    FOREIGN KEY ([ApplicationId])
    REFERENCES [dbo].[aspnet_Applications]
        ([ApplicationId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK__aspnet_Ro__Appli__075714DC'
CREATE INDEX [IX_FK__aspnet_Ro__Appli__075714DC]
ON [dbo].[aspnet_Roles]
    ([ApplicationId]);
GO

-- Creating foreign key on [ApplicationId] in table 'aspnet_Users'
ALTER TABLE [dbo].[aspnet_Users]
ADD CONSTRAINT [FK__aspnet_Us__Appli__589C25F3]
    FOREIGN KEY ([ApplicationId])
    REFERENCES [dbo].[aspnet_Applications]
        ([ApplicationId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK__aspnet_Us__Appli__589C25F3'
CREATE INDEX [IX_FK__aspnet_Us__Appli__589C25F3]
ON [dbo].[aspnet_Users]
    ([ApplicationId]);
GO

-- Creating foreign key on [UserId] in table 'aspnet_Membership'
ALTER TABLE [dbo].[aspnet_Membership]
ADD CONSTRAINT [FK__aspnet_Me__UserI__69C6B1F5]
    FOREIGN KEY ([UserId])
    REFERENCES [dbo].[aspnet_Users]
        ([UserId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [PathId] in table 'aspnet_PersonalizationAllUsers'
ALTER TABLE [dbo].[aspnet_PersonalizationAllUsers]
ADD CONSTRAINT [FK__aspnet_Pe__PathI__2022C2A6]
    FOREIGN KEY ([PathId])
    REFERENCES [dbo].[aspnet_Paths]
        ([PathId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [PathId] in table 'aspnet_PersonalizationPerUser'
ALTER TABLE [dbo].[aspnet_PersonalizationPerUser]
ADD CONSTRAINT [FK__aspnet_Pe__PathI__23F3538A]
    FOREIGN KEY ([PathId])
    REFERENCES [dbo].[aspnet_Paths]
        ([PathId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK__aspnet_Pe__PathI__23F3538A'
CREATE INDEX [IX_FK__aspnet_Pe__PathI__23F3538A]
ON [dbo].[aspnet_PersonalizationPerUser]
    ([PathId]);
GO

-- Creating foreign key on [UserId] in table 'aspnet_PersonalizationPerUser'
ALTER TABLE [dbo].[aspnet_PersonalizationPerUser]
ADD CONSTRAINT [FK__aspnet_Pe__UserI__24E777C3]
    FOREIGN KEY ([UserId])
    REFERENCES [dbo].[aspnet_Users]
        ([UserId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK__aspnet_Pe__UserI__24E777C3'
CREATE INDEX [IX_FK__aspnet_Pe__UserI__24E777C3]
ON [dbo].[aspnet_PersonalizationPerUser]
    ([UserId]);
GO

-- Creating foreign key on [UserId] in table 'aspnet_Profile'
ALTER TABLE [dbo].[aspnet_Profile]
ADD CONSTRAINT [FK__aspnet_Pr__UserI__7DCDAAA2]
    FOREIGN KEY ([UserId])
    REFERENCES [dbo].[aspnet_Users]
        ([UserId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [ClaimPaymentStatusId] in table 'MemberClaim'
ALTER TABLE [dbo].[MemberClaim]
ADD CONSTRAINT [FK_MemberClaim_ClaimPaymentStatus]
    FOREIGN KEY ([ClaimPaymentStatusId])
    REFERENCES [dbo].[ClaimPaymentStatus]
        ([ClaimPaymentStatusId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_MemberClaim_ClaimPaymentStatus'
CREATE INDEX [IX_FK_MemberClaim_ClaimPaymentStatus]
ON [dbo].[MemberClaim]
    ([ClaimPaymentStatusId]);
GO

-- Creating foreign key on [ClaimTypeId] in table 'MemberClaim'
ALTER TABLE [dbo].[MemberClaim]
ADD CONSTRAINT [FK_MemberClaim_ClaimType]
    FOREIGN KEY ([ClaimTypeId])
    REFERENCES [dbo].[ClaimType]
        ([ClaimTypeId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_MemberClaim_ClaimType'
CREATE INDEX [IX_FK_MemberClaim_ClaimType]
ON [dbo].[MemberClaim]
    ([ClaimTypeId]);
GO

-- Creating foreign key on [ClientId] in table 'Person'
ALTER TABLE [dbo].[Person]
ADD CONSTRAINT [FK_Person_Client]
    FOREIGN KEY ([ClientId])
    REFERENCES [dbo].[Client]
        ([ClientId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Person_Client'
CREATE INDEX [IX_FK_Person_Client]
ON [dbo].[Person]
    ([ClientId]);
GO

-- Creating foreign key on [EmployeeContributionType] in table 'MemberTransaction'
ALTER TABLE [dbo].[MemberTransaction]
ADD CONSTRAINT [FK_MemberTransaction_ContributionType]
    FOREIGN KEY ([EmployeeContributionType])
    REFERENCES [dbo].[ContributionType]
        ([ContributionTypeId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_MemberTransaction_ContributionType'
CREATE INDEX [IX_FK_MemberTransaction_ContributionType]
ON [dbo].[MemberTransaction]
    ([EmployeeContributionType]);
GO

-- Creating foreign key on [AddVoluntaryContributionTypeId] in table 'MemberTransaction'
ALTER TABLE [dbo].[MemberTransaction]
ADD CONSTRAINT [FK_MemberTransaction_ContributionType1]
    FOREIGN KEY ([AddVoluntaryContributionTypeId])
    REFERENCES [dbo].[ContributionType]
        ([ContributionTypeId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_MemberTransaction_ContributionType1'
CREATE INDEX [IX_FK_MemberTransaction_ContributionType1]
ON [dbo].[MemberTransaction]
    ([AddVoluntaryContributionTypeId]);
GO

-- Creating foreign key on [EmployerContributionTypeId] in table 'MemberTransaction'
ALTER TABLE [dbo].[MemberTransaction]
ADD CONSTRAINT [FK_MemberTransaction_ContributionType2]
    FOREIGN KEY ([EmployerContributionTypeId])
    REFERENCES [dbo].[ContributionType]
        ([ContributionTypeId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_MemberTransaction_ContributionType2'
CREATE INDEX [IX_FK_MemberTransaction_ContributionType2]
ON [dbo].[MemberTransaction]
    ([EmployerContributionTypeId]);
GO

-- Creating foreign key on [EmployerStatusId] in table 'Employer'
ALTER TABLE [dbo].[Employer]
ADD CONSTRAINT [FK_Employer_EmployerStatus]
    FOREIGN KEY ([EmployerStatusId])
    REFERENCES [dbo].[EmployerStatus]
        ([EmployerStatusId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Employer_EmployerStatus'
CREATE INDEX [IX_FK_Employer_EmployerStatus]
ON [dbo].[Employer]
    ([EmployerStatusId]);
GO

-- Creating foreign key on [FundId] in table 'Employer'
ALTER TABLE [dbo].[Employer]
ADD CONSTRAINT [FK_Employer_Fund]
    FOREIGN KEY ([FundId])
    REFERENCES [dbo].[Fund]
        ([FundId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Employer_Fund'
CREATE INDEX [IX_FK_Employer_Fund]
ON [dbo].[Employer]
    ([FundId]);
GO

-- Creating foreign key on [EmployerId] in table 'Member'
ALTER TABLE [dbo].[Member]
ADD CONSTRAINT [FK_Member_Employer]
    FOREIGN KEY ([EmployerId])
    REFERENCES [dbo].[Employer]
        ([EmployerId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Member_Employer'
CREATE INDEX [IX_FK_Member_Employer]
ON [dbo].[Member]
    ([EmployerId]);
GO

-- Creating foreign key on [EmployerId] in table 'Person'
ALTER TABLE [dbo].[Person]
ADD CONSTRAINT [FK_Person_Employer]
    FOREIGN KEY ([EmployerId])
    REFERENCES [dbo].[Employer]
        ([EmployerId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Person_Employer'
CREATE INDEX [IX_FK_Person_Employer]
ON [dbo].[Person]
    ([EmployerId]);
GO

-- Creating foreign key on [FundId] in table 'FundAnswerSheet'
ALTER TABLE [dbo].[FundAnswerSheet]
ADD CONSTRAINT [FK_FundAnswerSheet_Fund]
    FOREIGN KEY ([FundId])
    REFERENCES [dbo].[Fund]
        ([FundId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_FundAnswerSheet_Fund'
CREATE INDEX [IX_FK_FundAnswerSheet_Fund]
ON [dbo].[FundAnswerSheet]
    ([FundId]);
GO

-- Creating foreign key on [FundId] in table 'FundElectedPeriod'
ALTER TABLE [dbo].[FundElectedPeriod]
ADD CONSTRAINT [FK_FundElectedPeriod_Fund]
    FOREIGN KEY ([FundId])
    REFERENCES [dbo].[Fund]
        ([FundId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_FundElectedPeriod_Fund'
CREATE INDEX [IX_FK_FundElectedPeriod_Fund]
ON [dbo].[FundElectedPeriod]
    ([FundId]);
GO

-- Creating foreign key on [FundId] in table 'FundSLA'
ALTER TABLE [dbo].[FundSLA]
ADD CONSTRAINT [FK_FundSLA_Fund]
    FOREIGN KEY ([FundId])
    REFERENCES [dbo].[Fund]
        ([FundId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_FundSLA_Fund'
CREATE INDEX [IX_FK_FundSLA_Fund]
ON [dbo].[FundSLA]
    ([FundId]);
GO

-- Creating foreign key on [FundId] in table 'uaUserFund'
ALTER TABLE [dbo].[uaUserFund]
ADD CONSTRAINT [FK_uaUserFund_Fund]
    FOREIGN KEY ([FundId])
    REFERENCES [dbo].[Fund]
        ([FundId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_uaUserFund_Fund'
CREATE INDEX [IX_FK_uaUserFund_Fund]
ON [dbo].[uaUserFund]
    ([FundId]);
GO

-- Creating foreign key on [QuestionId] in table 'FundAnswerSheet'
ALTER TABLE [dbo].[FundAnswerSheet]
ADD CONSTRAINT [FK_FundAnswerSheet_Question]
    FOREIGN KEY ([QuestionId])
    REFERENCES [dbo].[Question]
        ([QuestionId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_FundAnswerSheet_Question'
CREATE INDEX [IX_FK_FundAnswerSheet_Question]
ON [dbo].[FundAnswerSheet]
    ([QuestionId]);
GO

-- Creating foreign key on [FundElectedPeriodId] in table 'FundElectedPeriodTrustee'
ALTER TABLE [dbo].[FundElectedPeriodTrustee]
ADD CONSTRAINT [FK_FundElectedPeriodTrustee_FundElectedPeriod]
    FOREIGN KEY ([FundElectedPeriodId])
    REFERENCES [dbo].[FundElectedPeriod]
        ([FundElectedPeriodId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [LanguageId] in table 'Member'
ALTER TABLE [dbo].[Member]
ADD CONSTRAINT [FK_Member_Language]
    FOREIGN KEY ([LanguageId])
    REFERENCES [dbo].[Language]
        ([LanguagId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Member_Language'
CREATE INDEX [IX_FK_Member_Language]
ON [dbo].[Member]
    ([LanguageId]);
GO

-- Creating foreign key on [MemberStatusId] in table 'Member'
ALTER TABLE [dbo].[Member]
ADD CONSTRAINT [FK_Member_MemberStatus]
    FOREIGN KEY ([MemberStatusId])
    REFERENCES [dbo].[MemberStatus]
        ([MemberStatusId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Member_MemberStatus'
CREATE INDEX [IX_FK_Member_MemberStatus]
ON [dbo].[Member]
    ([MemberStatusId]);
GO

-- Creating foreign key on [RemunerationType] in table 'Member'
ALTER TABLE [dbo].[Member]
ADD CONSTRAINT [FK_Member_RemunerationType]
    FOREIGN KEY ([RemunerationType])
    REFERENCES [dbo].[RemunerationType]
        ([RemunerationTypeId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Member_RemunerationType'
CREATE INDEX [IX_FK_Member_RemunerationType]
ON [dbo].[Member]
    ([RemunerationType]);
GO

-- Creating foreign key on [MemberId] in table 'MemberClaim'
ALTER TABLE [dbo].[MemberClaim]
ADD CONSTRAINT [FK_MemberClaim_Member]
    FOREIGN KEY ([MemberId])
    REFERENCES [dbo].[Member]
        ([MemberId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_MemberClaim_Member'
CREATE INDEX [IX_FK_MemberClaim_Member]
ON [dbo].[MemberClaim]
    ([MemberId]);
GO

-- Creating foreign key on [MemberId] in table 'MemberTransaction'
ALTER TABLE [dbo].[MemberTransaction]
ADD CONSTRAINT [FK_MemberTransaction_Member]
    FOREIGN KEY ([MemberId])
    REFERENCES [dbo].[Member]
        ([MemberId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_MemberTransaction_Member'
CREATE INDEX [IX_FK_MemberTransaction_Member]
ON [dbo].[MemberTransaction]
    ([MemberId]);
GO

-- Creating foreign key on [MemberClaimId] in table 'MemberPayment'
ALTER TABLE [dbo].[MemberPayment]
ADD CONSTRAINT [FK_MemberPayment_MemberClaim]
    FOREIGN KEY ([MemberClaimId])
    REFERENCES [dbo].[MemberClaim]
        ([MemberClaimId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_MemberPayment_MemberClaim'
CREATE INDEX [IX_FK_MemberPayment_MemberClaim]
ON [dbo].[MemberPayment]
    ([MemberClaimId]);
GO

-- Creating foreign key on [PaymentMethodId] in table 'MemberPayment'
ALTER TABLE [dbo].[MemberPayment]
ADD CONSTRAINT [FK_MemberPayment_PaymentMethod]
    FOREIGN KEY ([PaymentMethodId])
    REFERENCES [dbo].[PaymentMethod]
        ([PaymentMethodId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_MemberPayment_PaymentMethod'
CREATE INDEX [IX_FK_MemberPayment_PaymentMethod]
ON [dbo].[MemberPayment]
    ([PaymentMethodId]);
GO

-- Creating foreign key on [PaymentStatusId] in table 'MemberPayment'
ALTER TABLE [dbo].[MemberPayment]
ADD CONSTRAINT [FK_MemberPayment_PaymentStatus]
    FOREIGN KEY ([PaymentStatusId])
    REFERENCES [dbo].[PaymentStatus]
        ([PaymentStatusId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_MemberPayment_PaymentStatus'
CREATE INDEX [IX_FK_MemberPayment_PaymentStatus]
ON [dbo].[MemberPayment]
    ([PaymentStatusId]);
GO

-- Creating foreign key on [PaymentTypeId] in table 'MemberPayment'
ALTER TABLE [dbo].[MemberPayment]
ADD CONSTRAINT [FK_MemberPayment_PaymentType]
    FOREIGN KEY ([PaymentTypeId])
    REFERENCES [dbo].[PaymentType]
        ([PaymentTypeId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_MemberPayment_PaymentType'
CREATE INDEX [IX_FK_MemberPayment_PaymentType]
ON [dbo].[MemberPayment]
    ([PaymentTypeId]);
GO

-- Creating foreign key on [PositionId] in table 'Person'
ALTER TABLE [dbo].[Person]
ADD CONSTRAINT [FK_People_Position]
    FOREIGN KEY ([PositionId])
    REFERENCES [dbo].[Position]
        ([PositionId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_People_Position'
CREATE INDEX [IX_FK_People_Position]
ON [dbo].[Person]
    ([PositionId]);
GO

-- Creating foreign key on [TitleId] in table 'Person'
ALTER TABLE [dbo].[Person]
ADD CONSTRAINT [FK_People_Title]
    FOREIGN KEY ([TitleId])
    REFERENCES [dbo].[Title]
        ([TitleId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_People_Title'
CREATE INDEX [IX_FK_People_Title]
ON [dbo].[Person]
    ([TitleId]);
GO

-- Creating foreign key on [PersonTypeId] in table 'Person'
ALTER TABLE [dbo].[Person]
ADD CONSTRAINT [FK_Person_PersonType]
    FOREIGN KEY ([PersonTypeId])
    REFERENCES [dbo].[PersonType]
        ([PersonTypeId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Person_PersonType'
CREATE INDEX [IX_FK_Person_PersonType]
ON [dbo].[Person]
    ([PersonTypeId]);
GO

-- Creating foreign key on [QuestionGroupId] in table 'Question'
ALTER TABLE [dbo].[Question]
ADD CONSTRAINT [FK_AuditComm_QuestionGroup]
    FOREIGN KEY ([QuestionGroupId])
    REFERENCES [dbo].[QuestionGroup]
        ([QuestionGroupId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_AuditComm_QuestionGroup'
CREATE INDEX [IX_FK_AuditComm_QuestionGroup]
ON [dbo].[Question]
    ([QuestionGroupId]);
GO

-- Creating foreign key on [QuestionCategoryId] in table 'QuestionGroup'
ALTER TABLE [dbo].[QuestionGroup]
ADD CONSTRAINT [FK_QuestionGroup_Category]
    FOREIGN KEY ([QuestionCategoryId])
    REFERENCES [dbo].[QuestionCategory]
        ([QuestionCategoryId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_QuestionGroup_Category'
CREATE INDEX [IX_FK_QuestionGroup_Category]
ON [dbo].[QuestionGroup]
    ([QuestionCategoryId]);
GO

-- Creating foreign key on [uaGroupId] in table 'uaGroupRole'
ALTER TABLE [dbo].[uaGroupRole]
ADD CONSTRAINT [FK_uaGroupRole_uaGroup]
    FOREIGN KEY ([uaGroupId])
    REFERENCES [dbo].[uaGroup]
        ([uaGroupId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [uaRoleId] in table 'uaGroupRole'
ALTER TABLE [dbo].[uaGroupRole]
ADD CONSTRAINT [FK_uaGroupRole_uaRole]
    FOREIGN KEY ([uaRoleId])
    REFERENCES [dbo].[uaRole]
        ([uaRoleId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_uaGroupRole_uaRole'
CREATE INDEX [IX_FK_uaGroupRole_uaRole]
ON [dbo].[uaGroupRole]
    ([uaRoleId]);
GO

-- Creating foreign key on [aspnet_Roles_RoleId] in table 'aspnet_UsersInRoles'
ALTER TABLE [dbo].[aspnet_UsersInRoles]
ADD CONSTRAINT [FK_aspnet_UsersInRoles_aspnet_Roles]
    FOREIGN KEY ([aspnet_Roles_RoleId])
    REFERENCES [dbo].[aspnet_Roles]
        ([RoleId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [aspnet_Users_UserId] in table 'aspnet_UsersInRoles'
ALTER TABLE [dbo].[aspnet_UsersInRoles]
ADD CONSTRAINT [FK_aspnet_UsersInRoles_aspnet_Users]
    FOREIGN KEY ([aspnet_Users_UserId])
    REFERENCES [dbo].[aspnet_Users]
        ([UserId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_aspnet_UsersInRoles_aspnet_Users'
CREATE INDEX [IX_FK_aspnet_UsersInRoles_aspnet_Users]
ON [dbo].[aspnet_UsersInRoles]
    ([aspnet_Users_UserId]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------